﻿Imports System.Configuration
Imports System.Collections.Specialized
Imports System.Xml
Imports System.Object
Imports System.Collections
Imports System.IO
Imports System.Windows.Forms
Imports Microsoft.VisualBasic.ControlChars


Public Class frmMain

#Region "(Removed) Public Shared Variables"
    '    Public Shared iSaveType As Integer = 1
    '    ' iSaveType = 1: save XML to permanent file; 
    '    ' iSaveType = 2: save XML to temporary file and perform CRLF substitution
    '    Public Shared strParaMarker As String = "mvcrlf*" 'marks paragraph breaks for HTML conversion feature
    '    Public Shared strParaHTML As String = "<br/>" 'replaces strParaMarker in final HTML conversion output
    '    Public Shared strFileToSave As String = "" 'string holding the file name
    '    Public Shared xmlHeader As XmlDocument
    '    Public Shared strStylesheet1 As String = "<?xml-stylesheet href="
    '    Public Shared strStylesheet2 As String = " type='text/xsl'?>"
    '    Public Shared strCurHref As String = ""
    '    Public Shared xmlIDsection As XmlNode
    '    Public Shared xmlDQIsection As XmlNode
    '    Public Shared xmlSDOsection As XmlNode
    '    Public Shared xmlSpaRefSection As XmlNode
    '    Public Shared xmlEAsection As XmlNode
    '    Public Shared xmlDistSection As XmlDocumentFragment
    '    Public Shared xmlMetaRefSection As XmlNode
    '    Private Shared xmlInputDOM As New XmlDocument 'used for opening files

    '    Public Shared bActiveFile As Boolean = False 'True if New or Open file
    '    Public Shared bTimeUsed As Boolean = False 'True if the metadata includes a time of day entry (not Geologic); 
    '    'used to trigger inclusion of Metadata Time Convention in Metadata Reference section

    '    'Citation information for ID section; the Boolean tells whether there is a larger work citation to process
    '    Public Shared objCitation As CiteInfo
    '    Public Shared objCitationLWork As CiteInfo
    '    Public Shared bCitationLWork As Boolean

    '    Public Shared IDtimeper As Collection

    '    'Private Shared xmlAttrib As XmlAttribute 'will be used to mark missing mandatory information

    '    'variables for ID: spatial domain
    '    Public Shared sDataSetGPoly As StringCollection
    '    Public Shared sCountGPoly As StringCollection
    '    Public Shared sPdelim As String = "£"

    '    'variables for ID: keywords
    '    Public Shared sKeyTheme As StringCollection
    '    Public Shared sKeyPlace As StringCollection
    '    Public Shared sKeyStratum As StringCollection
    '    Public Shared sKeyTemporal As StringCollection
    '    Public Shared sKdelim As String = CrLf

    '    'variables for ID: taxonomy
    '    Public Shared sTaxKeywords As StringCollection
    '    Public Shared citeTaxSys As Collection 'holds the main citation information for Taxonomic System
    '    Public Shared boolTaxSys As Collection 'holds Booleans indicating whether LWC is used
    '    Public Shared citeTaxSysLWC As Collection 'holds larger work citations
    '    Public Shared sTaxSysMods As StringCollection 'holds the Taxonomic System modifications
    '    Public Shared citeTaxIDRef As Collection 'holds the main citation information for Identification Reference
    '    Public Shared boolTaxIDRef As Collection 'holds Booleans indicating whether LWC is used
    '    Public Shared citeTaxIDRefLWC As Collection 'holds larger work citations
    '    Public Shared cntTaxID As Collection 'holds contact information for Identifier(s) -- optional
    '    Public Shared sVSpecimen As StringCollection 'holds the specimen info for vouchers
    '    Public Shared cntVouchers As Collection 'holds the contact info for voucher repository
    '    Public Shared TaxaClasses As Collection 'holds the taxonomic classification entries
    '    Public Shared xmlTaxonClass As XmlDocument 'holds the Taxonomic Classification

    '    'variables for ID: access
    '    Public Shared objDataContact As ContactInfo

    '    'variables for ID: analytical tools
    '    Public Shared idTools As Collection

    '    'variables for ID: miscellaneous
    '    Public Shared sBrowseGraphics As StringCollection
    '    Public Shared XRefBase As Collection
    '    Public Shared bXRefLWC As Collection
    '    Public Shared XRefLarge As Collection


    '    'variables for Data Quality
    '    Public Shared sAttribAcc As StringCollection
    '    Public Shared sHPosAcc As StringCollection
    '    Public Shared sVPosAcc As StringCollection
    '    Public Shared cMethods As New Collection
    '    Public Shared cSources As New Collection
    '    Public Shared cProcess As New Collection


    '    'variables for Spatial Data Organization
    '    Public Shared sSDTS As StringCollection 'holds collection of SDTS or VPF terms descriptions, if used
    '    Public Shared bSDTS As Boolean 'True if SDTS terms description selected
    '    Public Shared bVPF As Boolean 'True if VPF terms description selected


    '    'variables for Spatial Reference Information
    '    Public Shared cPlanar As New Collection
    '    Private Shared sPlanProjParams(29) As String


    '    'variables for Entity and Attribute Information
    '    Public Shared cEAentity As New Collection 'the detail descriptions
    '    Public Shared cEAttribs As New Collection    'the attributes associated with detailed descriptions
    '    Public Shared cEAdomains As New Collection   'the domain values associated with attributes
    '    Public Shared cEAdomtype As New StringCollection 'the domain types in the domain values collection, effectively 1-based
    '    Public Shared cEAttrOver As New Collection   'the overview descriptions
    '    Private Shared iRootIndex As Integer = 0 'index value for root element
    '    Private Shared iBranchIndex As Integer = 0 'index value for branch element
    '    Private Shared sRootType As String = "" 'type of root -- entity, attribute, domain
    '    Private Shared sBranchType As String = "" 'type of branch -- attribute or domain


    '    'variables for Distribution Information
    '    Public Shared cDistrib As New Collection 'the distributors of the data set
    '    Public Shared cStdOrderProc As New Collection 'standard order process descriptions
    '    Public Shared cDigitalForm As New Collection 'Digital forms for the standard order processes
    '    Public Shared cDTransOpt As New Collection 'Digital Transfer Options for Digital Forms

    '    'variables for Metadata Reference section
    '    Public Shared objMRcontact As ContactInfo
#End Region

#Region "(Checked) Public Variables"
    'intTimeStyle indicates which time format is used in the documentation; only 1 format is allowed in a given document
    '             default is local time; all formats use a 24-hour clock
    '             value can be changed in Options menu
    'change generates non-modal list of fields to update; if no update at Save, then delete that Time node
    'intTimeStyle = 1: local time
    '               2: local time with GMT differential
    '               3: Universal time
    Public Shared intTimeStyle As Integer
    Public Function getTimeStyle() As Integer
        Return intTimeStyle
    End Function
#End Region

#Region "(Checked) public variables for forms and panels"
    'Public Shared ReadOnly Property AppSettings() As NameValueCollection
    Public Shared f11 As New frmTabBasicInfo
    Public Shared f12 As New frmTabSpatialDomain
    Public Shared f13 As New frmTabKeywords
    Public Shared f14 As New frmTabTaxonomy
    Public Shared f15 As New frmTabAccess
    Public Shared f16 As New frmTabAnalyticalTools
    Public Shared f17 As New frmTabMiscellaneous
    Public Shared f21 As New frmTabAttributeAccuracy
    Public Shared f22 As New frmTabConsistencyCompleteness
    Public Shared f23 As New frmTabPositionalAccuracy
    Public Shared f24 As New frmTabLineage
    Public Shared f25 As New frmTabCloudCover
    Public Shared f31 As New frmTabReferenceMethod
    Public Shared f32 As New frmTabVectorInformation
    Public Shared f33 As New frmTabRasterInformation
    Public Shared f41 As New frmTabHorizontalCoordinate
    Public Shared f42 As New frmTabVerticalCoordinate
    Public Shared f51 As New frmTabDetailedDescription
    Public Shared f52 As New frmTabOverviewDescription
    'Public Shared f53 As New frmTabInformation
    Public Shared f61 As New frmTabDistributors
    'Public Shared f62 As New frmTabInformation2
    Public Shared f71 As New frmTabMetadataInformation
    Public Shared f72 As New frmTabExtensions
    Public Shared f73 As New frmTabConstraintsSecurity
    Dim panel11 As New Panel
    Dim panel12 As New Panel
    Dim panel13 As New Panel
    Dim panel14 As New Panel
    Dim panel15 As New Panel
    Dim panel16 As New Panel
    Dim panel17 As New Panel
    Dim panel21 As New Panel
    Dim panel22 As New Panel
    Dim panel23 As New Panel
    Dim panel24 As New Panel
    Dim panel25 As New Panel
    Dim panel31 As New Panel
    Dim panel32 As New Panel
    Dim panel33 As New Panel
    Dim panel41 As New Panel
    Dim panel42 As New Panel
    Dim panel51 As New Panel
    Dim panel52 As New Panel
    'Dim panel53 As New Panel
    Dim panel61 As New Panel
    'Dim panel62 As New Panel
    Dim panel71 As New Panel
    Dim panel72 As New Panel
    Dim panel73 As New Panel
#End Region

#Region "(Checked) Form Load Function and xml generated menu and tabs"
    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        setFormAttr()
        TreeViewMenu()
        tip_showhidemenu.SetToolTip(form_buttonShowHideMenu, "Hide the Menu")
        runFileInitialize(False)
    End Sub

    Private Sub setFormAttr()
        'Set the form attributes for the forms on the tabs
        f11.TopLevel = False
        f12.TopLevel = False
        f13.TopLevel = False
        f14.TopLevel = False
        f15.TopLevel = False
        f16.TopLevel = False
        f17.TopLevel = False
        f21.TopLevel = False
        f22.TopLevel = False
        f23.TopLevel = False
        f24.TopLevel = False
        f25.TopLevel = False
        f31.TopLevel = False
        f32.TopLevel = False
        f33.TopLevel = False
        f41.TopLevel = False
        f42.TopLevel = False
        f51.TopLevel = False
        f52.TopLevel = False
        'f53.TopLevel = False
        f61.TopLevel = False
        'f62.TopLevel = False
        f71.TopLevel = False
        f72.TopLevel = False
        f73.TopLevel = False

        f11.Dock() = DockStyle.Fill
        f12.Dock() = DockStyle.Fill
        f13.Dock() = DockStyle.Fill
        f14.Dock() = DockStyle.Fill
        f15.Dock() = DockStyle.Fill
        f16.Dock() = DockStyle.Fill
        f17.Dock() = DockStyle.Fill
        f21.Dock() = DockStyle.Fill
        f22.Dock() = DockStyle.Fill
        f23.Dock() = DockStyle.Fill
        f24.Dock() = DockStyle.Fill
        f25.Dock() = DockStyle.Fill
        f31.Dock() = DockStyle.Fill
        f32.Dock() = DockStyle.Fill
        f33.Dock() = DockStyle.Fill
        f41.Dock() = DockStyle.Fill
        f42.Dock() = DockStyle.Fill
        f51.Dock() = DockStyle.Fill
        f52.Dock() = DockStyle.Fill
        'f53.Dock() = DockStyle.Fill
        f61.Dock() = DockStyle.Fill
        'f62.Dock() = DockStyle.Fill
        f71.Dock() = DockStyle.Fill
        f72.Dock() = DockStyle.Fill
        f73.Dock() = DockStyle.Fill
        panel11.Dock() = DockStyle.Fill
        panel12.Dock() = DockStyle.Fill
        panel13.Dock() = DockStyle.Fill
        panel14.Dock() = DockStyle.Fill
        panel15.Dock() = DockStyle.Fill
        panel16.Dock() = DockStyle.Fill
        panel17.Dock() = DockStyle.Fill
        panel21.Dock() = DockStyle.Fill
        panel22.Dock() = DockStyle.Fill
        panel23.Dock() = DockStyle.Fill
        panel24.Dock() = DockStyle.Fill
        panel25.Dock() = DockStyle.Fill
        panel31.Dock() = DockStyle.Fill
        panel32.Dock() = DockStyle.Fill
        panel33.Dock() = DockStyle.Fill
        panel41.Dock() = DockStyle.Fill
        panel42.Dock() = DockStyle.Fill
        panel51.Dock() = DockStyle.Fill
        panel52.Dock() = DockStyle.Fill
        'panel53.Dock() = DockStyle.Fill
        panel61.Dock() = DockStyle.Fill
        'panel62.Dock() = DockStyle.Fill
        panel71.Dock() = DockStyle.Fill
        panel72.Dock() = DockStyle.Fill
        panel73.Dock() = DockStyle.Fill
    End Sub
    Private Sub TreeViewMenu()
        'Creates the forms on the tabs from the xml file
        Dim appSettings As NameValueCollection = ConfigurationManager.AppSettings

        Dim xml_file As String
        xml_file = appSettings("mainxml") 'main.xml is located on the app.config

        Dim xml_doc As New XmlDocument
        xml_doc.Load(xml_file)
        form_Treeview.Nodes.Clear()
        AddTreeViewChildNodes(form_Treeview.Nodes, xml_doc.DocumentElement)
    End Sub
    Private Sub AddTreeViewChildNodes(ByVal parent_nodes As TreeNodeCollection, ByVal xml_node As XmlNode)
        'Create the navigation treeview
        For Each child_node As XmlNode In xml_node.ChildNodes
            Dim new_node As TreeNode = parent_nodes.Add(child_node.Attributes("key").Value, child_node.Attributes("name").Value)
            Try
                Select Case child_node.Attributes("type").Value
                    Case "MAN" 'Mandatory Sections
                        new_node.ImageIndex = 1
                        new_node.SelectedImageIndex = 1
                    Case "MIA" 'Mandatory if Applicable Sections
                        new_node.ImageIndex = 2
                        new_node.SelectedImageIndex = 2
                    Case "OPT" 'Optional Sections
                        new_node.ImageIndex = 3
                        new_node.SelectedImageIndex = 3
                    Case "INF" 'Information Sections
                        new_node.ImageIndex = 0
                        new_node.SelectedImageIndex = 0
                    Case "CAT" 'Main Category Sections
                        new_node.ImageIndex = 4
                        new_node.SelectedImageIndex = 4
                End Select
            Catch
            End Try

            ' Recursively make this node's descendants.
            AddTreeViewChildNodes(new_node.Nodes, child_node)
            If new_node.Nodes.Count = 0 Then new_node.EnsureVisible()
        Next child_node
    End Sub

    Private Sub form_Treeview_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles form_Treeview.AfterSelect
        'Each tab is generated with the form after each select operation
        If form_Treeview.SelectedNode.Nodes.Count <> 0 Then
            FillTabs(form_Treeview.SelectedNode.Nodes)
            showPanel(form_Treeview.SelectedNode.Nodes(0).Name)
        ElseIf form_Treeview.SelectedNode.Parent().Nodes.Count <> 0 Then
            FillTabs(form_Treeview.SelectedNode.Parent().Nodes)
            Dim index As Integer
            index = 0
            Dim selectedNode As New TreeNode
            selectedNode = form_Treeview.SelectedNode
            Try
                Do While selectedNode.PrevNode.Nodes.Count <= 0
                    index = index + 1
                    selectedNode = selectedNode.PrevNode
                Loop
            Catch ex As Exception
            End Try
            form_TabControl.SelectedIndex = index
            showPanel(form_Treeview.SelectedNode.Name)
        End If
    End Sub
    Private Sub FillTabs(ByVal nodes As TreeNodeCollection)
        'Tabs are filled with the forms
        form_TabControl.TabPages.Clear()

        Dim newtab As New TabPage

        For Each childnode As TreeNode In nodes
            'newtab.Text = childnode.Text
            'newtab.Name = "tab_" & childnode.Text.Trim
            form_TabControl.TabPages.Add(childnode.Name, childnode.Text)

            hideTabForms()

            Try
                adjustPanel(childnode.Name)
                form_TabControl.TabPages(childnode.Name).ImageIndex = childnode.ImageIndex
            Catch ex As Exception
            End Try
        Next
    End Sub
    Private Sub hideTabForms()
        'Hides the forms on the tabs
        f11.Hide()
        f12.Hide()
        f13.Hide()
        f14.Hide()
        f15.Hide()
        f16.Hide()
        f17.Hide()
        f21.Hide()
        f22.Hide()
        f23.Hide()
        f24.Hide()
        f25.Hide()
        f31.Hide()
        f32.Hide()
        f33.Hide()
        f41.Hide()
        f42.Hide()
        f51.Hide()
        f52.Hide()
        'f53.Hide()
        f61.Hide()
        'f62.Hide()
        f71.Hide()
        f72.Hide()
        f73.Hide()
    End Sub
    Private Sub adjustPanel(ByVal tabName As String)
        'Adds form pages to the panels in the tabs
        Select Case tabName
            Case "frmTabBasicInfo"
                panel11.Controls.Add(f11) : form_TabControl.TabPages(tabName).Controls.Add(panel11)
            Case "frmTabSpatialDomain"
                panel12.Controls.Add(f12) : form_TabControl.TabPages(tabName).Controls.Add(panel12)
            Case "frmTabKeywords"
                panel13.Controls.Add(f13) : form_TabControl.TabPages(tabName).Controls.Add(panel13)
            Case "frmTabTaxonomy"
                panel14.Controls.Add(f14) : form_TabControl.TabPages(tabName).Controls.Add(panel14)
            Case "frmTabAccess"
                panel15.Controls.Add(f15) : form_TabControl.TabPages(tabName).Controls.Add(panel15)
            Case "frmTabAnalyticalTools"
                panel16.Controls.Add(f16) : form_TabControl.TabPages(tabName).Controls.Add(panel16)
            Case "frmTabMiscellaneous"
                panel17.Controls.Add(f17) : form_TabControl.TabPages(tabName).Controls.Add(panel17)
            Case "frmTabAttributeAccuracy"
                panel21.Controls.Add(f21) : form_TabControl.TabPages(tabName).Controls.Add(panel21)
            Case "frmTabConsistencyCompleteness"
                panel22.Controls.Add(f22) : form_TabControl.TabPages(tabName).Controls.Add(panel22)
            Case "frmTabPositionalAccuracy"
                panel23.Controls.Add(f23) : form_TabControl.TabPages(tabName).Controls.Add(panel23)
            Case "frmTabLineage"
                panel24.Controls.Add(f24) : form_TabControl.TabPages(tabName).Controls.Add(panel24)
            Case "frmTabCloudCover"
                panel25.Controls.Add(f25) : form_TabControl.TabPages(tabName).Controls.Add(panel25)
            Case "frmTabReferenceMethod"
                panel31.Controls.Add(f31) : form_TabControl.TabPages(tabName).Controls.Add(panel31)
            Case "frmTabVectorInformation"
                panel32.Controls.Add(f32) : form_TabControl.TabPages(tabName).Controls.Add(panel32)
            Case "frmTabRasterInformation"
                panel33.Controls.Add(f33) : form_TabControl.TabPages(tabName).Controls.Add(panel33)
            Case "frmTabHorizontalCoordinate"
                panel41.Controls.Add(f41) : form_TabControl.TabPages(tabName).Controls.Add(panel41)
            Case "frmTabVerticalCoordinate"
                panel42.Controls.Add(f42) : form_TabControl.TabPages(tabName).Controls.Add(panel42)
            Case "frmTabDetailedDescription"
                panel51.Controls.Add(f51) : form_TabControl.TabPages(tabName).Controls.Add(panel51)
            Case "frmTabOverviewDescription"
                panel52.Controls.Add(f52) : form_TabControl.TabPages(tabName).Controls.Add(panel52)
                'Case "frmTabInformation"
                '   panel53.Controls.Add(f53) : form_TabControl.TabPages(tabName).Controls.Add(panel53)
            Case "frmTabDistributors"
                panel61.Controls.Add(f61) : form_TabControl.TabPages(tabName).Controls.Add(panel61)
                'Case "frmTabInformation2"
                '  panel62.Controls.Add(f62) : form_TabControl.TabPages(tabName).Controls.Add(panel62)
            Case "frmTabMetadataInformation"
                panel71.Controls.Add(f71) : form_TabControl.TabPages(tabName).Controls.Add(panel71)
            Case "frmTabExtensions"
                panel72.Controls.Add(f72) : form_TabControl.TabPages(tabName).Controls.Add(panel72)
            Case "frmTabConstraintsSecurity"
                panel73.Controls.Add(f73) : form_TabControl.TabPages(tabName).Controls.Add(panel73)
        End Select
    End Sub
    Private Sub showPanel(ByVal tabName As String)
        'Shows the form according to the selection
        Select Case tabName
            Case "frmTabBasicInfo"
                f11.Show()
            Case "frmTabSpatialDomain"
                f12.Show()
            Case "frmTabKeywords"
                f13.Show()
            Case "frmTabTaxonomy"
                f14.Show()
            Case "frmTabAccess"
                f15.Show()
            Case "frmTabAnalyticalTools"
                f16.Show()
            Case "frmTabMiscellaneous"
                f17.Show()
            Case "frmTabAttributeAccuracy"
                f21.Show()
            Case "frmTabConsistencyCompleteness"
                f22.Show()
            Case "frmTabPositionalAccuracy"
                f23.Show()
            Case "frmTabLineage"
                f24.Show()
            Case "frmTabCloudCover"
                f25.Show()
            Case "frmTabReferenceMethod"
                f31.Show()
            Case "frmTabVectorInformation"
                f32.Show()
            Case "frmTabRasterInformation"
                f33.Show()
            Case "frmTabHorizontalCoordinate"
                f41.Show()
            Case "frmTabVerticalCoordinate"
                f42.Show()
            Case "frmTabDetailedDescription"
                f51.Show()
            Case "frmTabOverviewDescription"
                f52.Show()
                'Case "frmTabInformation"
                '   f53.Show()
            Case "frmTabDistributors"
                f61.Show()
                'Case "frmTabInformation2"
                '   f62.Show()
            Case "frmTabMetadataInformation"
                f71.Show()
            Case "frmTabExtensions"
                f72.Show()
            Case "frmTabConstraintsSecurity"
                f73.Show()
        End Select
    End Sub

    Private Sub form_Treeview_AfterCollapse(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles form_Treeview.AfterCollapse
        'Changes the category images to collapsed (Closed box)
        e.Node.SelectedImageIndex = 5
        e.Node.ImageIndex = 5
    End Sub
    Private Sub form_Treeview_AfterExpand(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles form_Treeview.AfterExpand
        'Changes the category images to expanded (OPen box)
        e.Node.SelectedImageIndex = 4
        e.Node.ImageIndex = 4
    End Sub
    Private Sub form_TabControl_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles form_TabControl.SelectedIndexChanged
        Try
            showPanel(form_TabControl.SelectedTab.Name)
        Catch ex As Exception
        End Try
    End Sub
#End Region

#Region "Main Functions"
    Public Shared iSaveType As Integer = 1

    Public Shared strFileToSave As String 'Metadata File Name
    Public Shared strCurHref As String 'XML Structure
    Public Shared strStylesheet1 As String = "<?xml-stylesheet href="
    Public Shared strStylesheet2 As String = " type='text/xsl'?>"
    Public Shared strParaMarker As String = "mvcrlf*" 'marks paragraph breaks for HTML conversion feature
    Public Shared strParaHTML As String = "<br/>" 'replaces strParaMarker in final HTML conversion output

    Public Shared sPdelim As String = "£"
    Public Shared sKdelim As String = CrLf

    Public Shared xmlHeader As XmlDocument
    Public Shared xmlDoc As XmlDocument 'used on operating on xml
    Private Shared xmlInputDOM As New XmlDocument 'used for opening files

    Public Shared xmlIDsection As XmlNode
    Public Shared xmlDQIsection As XmlNode
    Public Shared xmlSDOsection As XmlNode
    Public Shared xmlSpaRefSection As XmlNode
    Public Shared xmlEAsection As XmlNode
    Public Shared xmlDistSection As XmlDocumentFragment
    Public Shared xmlMetaRefSection As XmlNode

    Public Shared isFileModified As Boolean = False
    Public Shared isFileNamed As Boolean = False

    Private Sub runFileInitialize(ByVal isClearForms As Boolean)
        isFileModified = False
        isFileNamed = False
        strFileToSave = "temp.xml" 'reset name of metadata file
        Me.Text = "Metavist 2 — unsaved metadata"

        xmlHeader = New XmlDocument
        xmlDoc = New XmlDocument()
        'clear the header DOM, the section XML nodes, and all metadata elements
        If isClearForms Then InitialDOM()

        'set up new standard header DOM
        strCurHref = "'file:///" & Application.StartupPath & "\NBII_classic.xsl'"
        Dim strMetaHeader As String = "<?xml version='1.0'?>" & CrLf & _
               strStylesheet1 & strCurHref & strStylesheet2 & CrLf & _
               "<metadata>" & createEmptyXMLNodes() & "</metadata>"
        xmlDoc.LoadXml(strMetaHeader)
        xmlDoc.Save(strFileToSave)
    End Sub
    Private Function createEmptyXMLNodes() As String
        Dim level1 As String = "<idinfo>"
        level1 = level1 & "<citation><citeinfo><origin></origin><pubdate></pubdate><title></title><edition></edition><geoform></geoform><serinfo><sername></sername><issue></issue></serinfo><pubinfo><pubplace></pubplace><publish></publish></pubinfo><onlink></onlink></citeinfo></citation>"
        level1 = level1 & "<descript><abstract></abstract><purpose></purpose><supplinf></supplinf></descript>"
        level1 = level1 & "<timeperd><timeinfo></timeinfo><current></current></timeperd>"
        level1 = level1 & "<status><progress></progress><update></update></status>"
        level1 = level1 & "<spdom><descgeog></descgeog><bounding><westbc></westbc><eastbc></eastbc><northbc></northbc><southbc></southbc></bounding></spdom>"
        level1 = level1 & "<keywords></keywords>"
        level1 = level1 & "<taxonomy><taxonsys><taxonpro></taxonpro><taxoncom></taxoncom></taxonsys><taxongen></taxongen></taxonomy>"
        level1 = level1 & "<accconst></accconst>"
        level1 = level1 & "<useconst></useconst>"
        level1 = level1 & "<secinfo><secsys></secsys><secclass></secclass><sechandl></sechandl></secinfo>"
        level1 = level1 & "<datacred></datacred>"
        level1 = level1 & "<native></native>"
        level1 = level1 & "</idinfo>"

        Dim level2 As String = "<dataqual>"
        level2 = level2 & "<attracc><attraccr></attraccr></attracc>"
        level2 = level2 & "<logic></logic>"
        level2 = level2 & "<complete></complete>"
        level2 = level2 & "<posacc><horizpa><horizpar></horizpar></horizpa><vertacc><vertaccr></vertaccr></vertacc></posacc>"
        level2 = level2 & "<lineage><srcinfo><srccite><citeinfo><origin></origin><pubdate></pubdate><title></title><geoform></geoform><othercit></othercit></citeinfo></srccite><typesrc></typesrc><srctime></srctime><srccitea></srccitea><srccontr></srccontr></srcinfo><procstep><procdesc></procdesc><procdate></procdate></procstep></lineage>"
        level2 = level2 & "<cloud></cloud>"
        level2 = level2 & "</dataqual>"

        Dim level3 As String = "<spdoinfo>"
        level3 = level3 & "<indspref></indspref>"
        level3 = level3 & "<direct></direct>"
        level3 = level3 & "</spdoinfo>"

        Dim level4 As String = "<spref>"
        level4 = level4 & "<horizsys><geodetic><horizdn></horizdn><ellips></ellips><semiaxis></semiaxis><denflat></denflat></geodetic></horizsys>"
        level4 = level4 & "<vertdef><altsys><altdatum></altdatum><altunits></altunits><altenc></altenc></altsys>"
        level4 = level4 & "<depthsys><depthdn></depthdn><depthdu></depthdu><depthem></depthem></depthsys></vertdef>"
        level4 = level4 & "</spref>"

        Dim level5 As String = "<eainfo>"
        level5 = level5 & "<detailed></detailed>"
        level5 = level5 & "</eainfo>"

        Dim level6 As String = "<distinfo>"
        level6 = level6 & "</distinfo>"

        Dim level7 As String = "<metainfo>"
        level7 = level7 & "<metd></metd><metrd></metrd><metfrd></metfrd>"
        level7 = level7 & "<metc><cntinfo><cntperp></cntperp><cntvoice></cntvoice><cntfax></cntfax><cntemail></cntemail></cntinfo></metc>"
        level7 = level7 & "<metstdn></metstdn><metstdv></metstdv>"
        level7 = level7 & "<metac></metac><metuc></metuc>"
        level7 = level7 & "<metsi><metscs></metscs><metsc></metsc><metshd></metshd></metsi>"
        level7 = level7 & "</metainfo>"

        Return level1 & level2 & level3 & level4 & level5 & level6 & level7
    End Function
    Private Sub runFileNew()
        If runFileClose() = 1 Then 'First Closes the file
            runFileInitialize(True) 'Initilize a new file
        End If
    End Sub
    Private Function runFileClose() As Integer
        If confirmation() = 1 Then
            Return 1
        Else
            Return 0
        End If
    End Function
    Private Function confirmation() As Integer
        Dim result As MsgBoxResult
        If (isFileModified) Then
            result = MsgBox("The metadata set has been changed." + vbCrLf + "Do you want to save the changes before closing?", MsgBoxStyle.YesNoCancel, "Metavist2")
        Else
            Return 1
        End If

        If result = MsgBoxResult.Yes Then
            runSave()
            Return 1
        ElseIf result = MsgBoxResult.Cancel Then
            Return 0
        ElseIf result = MsgBoxResult.No Then
            Return 1
        End If
    End Function
    Private Sub runSave()
        If (isFileNamed = False) Then
            SaveFileDialog1.ShowDialog()
            isFileNamed = True
            If (strFileToSave <> "") Then
                runFileSave(SaveFileDialog1.FileName)
            End If
        Else
            runFileSave("")
        End If
        isFileModified = False
    End Sub
    Private Sub runSaveAs()
        SaveFileDialog1.ShowDialog()
        isFileNamed = True
        If (SaveFileDialog1.FileName <> "") Then
            runFileSave(SaveFileDialog1.FileName)
        End If
        isFileModified = False
    End Sub
    Private Sub runFileSave(ByVal strFileRef As String)
        runEditXMLFiles()

        If strFileRef <> "" Then
            My.Computer.FileSystem.CopyFile(strFileToSave, strFileRef, True)
            strFileToSave = strFileRef
        End If

        'having successfully saved a file, add the file name to the window title if it was a permanent save
        If (isFileNamed) Then
            Dim sFileTemp As String = ""
            Dim sGenArray() As String
            Dim iBound As Integer = 0
            sGenArray = Split(strFileToSave, "\") 'break full file name into components
            iBound = sGenArray.GetUpperBound(0)   'get upper bound of array
            sFileTemp = sGenArray(iBound) 'get the last component -- should be the file name, no path info
            Me.Text = "Metavist 2 — " & sFileTemp
        End If
        isFileModified = False
    End Sub
    Private Sub runEditXMLFiles()
        f11.editXMLFile()
        f12.editXMLFile()
        f13.editXMLFile()
        f14.editXMLFile()
        f15.editXMLFile()
        f16.editXMLFile()
        f17.editXMLFile()
        f21.editXMLFile()
        f22.editXMLFile()
        f23.editXMLFile()
        f24.editXMLFile()
        f25.editXMLFile()
        f31.editXMLFile()
        f32.editXMLFile()
        f33.editXMLFile()
        f41.editXMLFile()
        f42.editXMLFile()
        f51.editXMLFile()
        f52.editXMLFile()
        f61.editXMLFile()
        f71.editXMLFile()
        f73.editXMLFile()
    End Sub
#End Region

#Region "File Open Operations"
    Private Sub runFileOpen()
        xmlInputDOM = New XmlDocument 'initialize the DOM

        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            Try
                'load XML into Document Object Model (DOM)
                xmlInputDOM.Load(OpenFileDialog1.FileName)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error loading XML from specified file", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Return
            End Try
        Else
            Return
        End If

        'file succesfully opened and XML loaded into xmlInputDOM
        'prepare to transfer metadata from xmlInputDOM to Metavist
        'runFileClose() 'close any existing file
        runFileNew() 'reinitialize the interface and variables

        'add the file name to the window title
        strFileToSave = OpenFileDialog1.FileName 'full file name for use in Save operations
        Dim sFileTemp As String = ""
        Dim sGenArray() As String
        Dim iBound As Integer = 0
        sGenArray = Split(strFileToSave, "\") 'break full file name into components
        iBound = sGenArray.GetUpperBound(0)   'get upper bound of array
        sFileTemp = sGenArray(iBound) 'get the last component -- should be the file name, no path info
        Me.Text = "Metavist 2 — " & sFileTemp

        'retrieve the style sheet info in the file, if any, and update
        Dim iCount As Integer = 0
        Dim iPosHRef As Integer = 0
        Dim iPosEq As Integer = 0
        Dim iPosEnd As Integer = 0
        Dim xmlNList As XmlNodeList
        Dim xmlProcNode As XmlNode
        Dim sProcInsVal As String = ""
        Dim sProcDelim As String = ""
        xmlNList = xmlInputDOM.SelectNodes("/processing-instruction('xml-stylesheet')")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'retrieve last stylesheet in tree
            'last stylesheet is the one used for presentation in browser, so is assumed active
            xmlProcNode = xmlNList.Item(iCount - 1) 'zero-based list of nodes
            sProcInsVal = xmlProcNode.Value
            iPosHRef = sProcInsVal.IndexOf("href")
            iPosEq = sProcInsVal.IndexOf("=", iPosHRef)
            sProcInsVal = sProcInsVal.Substring(iPosEq + 1) 'eliminates href and equal sign, preserves rest of substring
            sProcInsVal = sProcInsVal.TrimStart
            sProcDelim = sProcInsVal.Substring(0, 1) 'gets the delimiter character
            iPosEnd = sProcInsVal.IndexOf(sProcDelim, 1) 'gets position of ending delimiter
            If (iPosEnd <= 0) Then
                'no change to std stylesheet -- malformed processing instruction
            Else
                iPosEnd = iPosEnd + 1 'length of href identifier
                strCurHref = sProcInsVal.Substring(0, iPosEnd)
                InitialDOM() 'reset the XML
                'load new stylesheet processing instruction
                Dim strMetaHeader As String = "<?xml version='1.0'?>" & CrLf & _
                       strStylesheet1 & strCurHref & strStylesheet2 & CrLf & _
                       "<metadata>" & CrLf & "</metadata>"
                xmlHeader.LoadXml(strMetaHeader)
            End If
        Else
            'use standard stylesheet processing instruction
            strCurHref = "'NBII_classic.xsl'"
            Dim strMetaHeader As String = "<?xml version='1.0'?>" & CrLf & _
                   strStylesheet1 & strCurHref & strStylesheet2 & CrLf & _
                   "<metadata>" & CrLf & "</metadata>"
            xmlHeader.LoadXml(strMetaHeader)
        End If

        'update the time format used, if present
        Dim sError As String = ""
        xmlNList = xmlInputDOM.SelectNodes("/metadata/metainfo/mettc")
        iCount = xmlNList.Count
        If (iCount = 0) Then
            'no element, so no change to default of local time
        Else
            xmlProcNode = xmlNList.Item(0) 'get the time format node from list
            sProcInsVal = xmlProcNode.InnerText
            Select Case sProcInsVal
                Case "local time"
                    localTime()
                Case "local time with time differential factor"
                    differTime()
                Case "universal time"
                    univTime()
                Case Else
                    sError = "File's value of " & sProcInsVal & "not valid member of domain." & CrLf
                    sError += "local time will be the format until you change the setting under Options"
                    MessageBox.Show(sError, "Time Convention Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Select
        End If

        'process the metadata sections
        openNBII()

    End Sub
    Private Sub runXMLstyle()
        Dim strMetaHeader As String = ""
        Dim strFileDesignator As String = "'file:///"
        Dim strTempPath As String = ""

        Dim frmUpdateStyle As New frmXMLchangeStyle(strCurHref)
        frmUpdateStyle.ShowDialog()

        strCurHref = frmUpdateStyle.strNewHref
        If (Len(strCurHref) > 0) Then
            If (strCurHref.StartsWith("'http://") Or strCurHref.StartsWith("'file:///")) Then
                strTempPath = strCurHref
            Else
                MessageBox.Show("modifying stylesheet path", "output", MessageBoxButtons.OK)
                strTempPath = strCurHref.Remove(0, 1)
                strTempPath = strFileDesignator & strTempPath
            End If
            strMetaHeader = "<?xml version='1.0'?>" & CrLf & _
            strStylesheet1 & strTempPath & strStylesheet2 & CrLf & _
            "<metadata>" & CrLf & "</metadata>"
        Else
            strMetaHeader = "<?xml version='1.0'?>" & CrLf & "<metadata>" & CrLf & "</metadata>"
        End If
        xmlHeader.LoadXml(strMetaHeader)
    End Sub
    Private Sub openNBII()
        Dim xmlOpenSect As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim sNBIIinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        'get the idinfo section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/idinfo")
        If (xmlNList.Count > 0) Then
            'max of 1 ID Info section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openID(xmlOpenSect)
        End If

        'get the dataqual section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/dataqual")
        If (xmlNList.Count > 0) Then
            'max of 1 Data Quality Info section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openDQ(xmlOpenSect)
        End If

        'get the spdoinfo section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/spdoinfo")
        If (xmlNList.Count > 0) Then
            'max of 1 Spatial Data Organization Info section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openSpDO(xmlOpenSect)
        End If

        'get the spref section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/spref")
        If (xmlNList.Count > 0) Then
            'max of 1 Spatial Reference Info section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openSpRef(xmlOpenSect)
        End If

        'get the eainfo section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/eainfo")
        If (xmlNList.Count > 0) Then
            'max of 1 Entity & Attribute Info section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openEA(xmlOpenSect)
        End If

        'get the distinfo section from the main XML document, if present
        'note that there can be more than 1 distinfo section!
        xmlNList = xmlInputDOM.SelectNodes("/metadata/distinfo")
        iCount = xmlNList.Count - 1
        For iLoop = 0 To iCount
            sNBIIinfo = xmlNList(iLoop).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openDistrib(xmlOpenSect)
        Next

        'get the metainfo section from the main XML document, if present
        xmlNList = xmlInputDOM.SelectNodes("/metadata/metainfo")
        If (xmlNList.Count > 0) Then
            'max of 1 Metadata Reference Information section
            sNBIIinfo = xmlNList(0).OuterXml
            xmlOpenSect.LoadXml(sNBIIinfo)
            openMR(xmlOpenSect)
        End If
    End Sub
    Private Sub evalDate(ByRef sCandidate As String, ByRef bTrans As Boolean)
        Dim iCheck As Integer = -10
        Dim iLength As Integer = 0
        Dim sTimeScale As String = ""
        Dim sCanDate As String = ""
        Dim sTest As String = ""

        bTrans = True 'initialize as a proper date
        sCanDate = sCandidate
        iLength = sCandidate.Length 'get the length of the proposed date string

        'evaluate whether date is Before Common Era (bc) or pre-Before Common Era (cc)
        If (iLength > 4) Then
            sTimeScale = sCandidate.Substring(0, 2)
            If (sTimeScale = "bc" Or sTimeScale = "cc") Then
                'adjust the string and its length to test just the date
                sCanDate = sCandidate.Substring(2)
                iLength = iLength - 2
            End If
        End If

        'make sure the candidate date is an integer and of the correct length
        If (sTimeScale = "cc") Then
            'minimum length is 5; maximum is arbitrarily set at 10 (1 billion) in the program -- earlier uses Geologic Age
            If (iLength > 4 And iLength < 11) Then
                'check to ensure positive integer
                Try
                    iCheck = Convert.ToInt32(sCanDate)
                    MessageBox.Show(iCheck.ToString, "converted integer", MessageBoxButtons.OK)
                Catch ex As Exception
                    bTrans = False
                    iCheck = -10
                End Try
                'check the value of the integer to fit in the bounds
                If (iCheck > 1000000000) Then
                    iCheck = 1000000000
                    sTest = "Input date of " & sCandidate & CrLf & "converted to " & sTimeScale & iCheck.ToString
                    sCandidate = sTimeScale & iCheck.ToString
                    MessageBox.Show(sTest, "Conversion of date – exceeded maximum value", MessageBoxButtons.OK)
                End If
                If (iCheck < 10000) Then
                    iCheck = 10000
                    sTest = "Input date of " & sCandidate & CrLf & "converted to " & sTimeScale & iCheck.ToString
                    sCandidate = sTimeScale & iCheck.ToString
                    MessageBox.Show(sTest, "Conversion of date – exceeded minimum value", MessageBoxButtons.OK)
                End If
            Else
                'not a proper cc date
                bTrans = False
            End If
        Else
            'bc and Common Era dates
            Select Case iLength
                Case 4, 6, 8
                    Try
                        iCheck = Convert.ToInt32(sCanDate)
                    Catch ex As Exception
                        bTrans = False
                    End Try
                    If (bTrans = True) Then
                        'check the value of the integer to fit in the bounds
                        If (iCheck < 1) Then
                            bTrans = False
                        End If
                    End If
                Case Else
                    bTrans = False
            End Select
        End If
    End Sub

#Region " DOM processing routines for ID Info section "

    Private Sub openID(ByVal xmlOpenID As XmlDocument)
        Dim xmlTempDoc As New XmlDocument
        Dim xmlTempSubDoc As New XmlDocument 'handles subsections of xmlTempDoc
        Dim xmlTimeDoc As New XmlDocument 'will handle Time Info sub-section
        Dim xmlNList As XmlNodeList
        Dim oCite As New CiteInfo 'for Citation
        Dim oNewContact As New ContactInfo
        Dim oSource As New SourceClass 'for Time Info
        Dim cIDTimeColl As New Collection 'for Time Info
        Dim s1 As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim bCheck As Boolean 'generic boolean
        Dim bCheck2 As Boolean 'another generic boolean

        'open Citation
        xmlNList = xmlOpenID.SelectNodes("/idinfo/citation/citeinfo")
        If (xmlNList.Count > 0) Then
            'get Citation Information node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/citation/citeinfo").OuterXml
            'the OuterXml will get a citeinfo, including any larger work citation nodes
        Else
            sIDinfo = ""
        End If

        'process XML if present
        If (sIDinfo <> "") Then
            'load the Citation Information
            xmlTempDoc.LoadXml(sIDinfo)
            f11.bCitationLWork = False 'larger work citation indicator
            bCheck = False 'local larger work citation indicator
            'need to call the citeinfo processing routine, then place results into public objects
            openCite(xmlTempDoc, oCite, bCheck)
            If (bCheck = True) Then
                f11.objCitation = oCite 'place citation information into public object
                'check for presence of a larger work citation
                xmlNList = xmlTempDoc.SelectNodes("/citeinfo/lworkcit")
                If (xmlNList.Count > 0) Then
                    'process the larger work citation
                    sIDinfo = xmlTempDoc.SelectSingleNode("/citeinfo/lworkcit").InnerXml
                    xmlTempSubDoc.LoadXml(sIDinfo) 'holds the larger work citation
                    'the InnerXml will get the citeinfo under lworkcit
                    'need to call the citeinfo processing routine, then place results into oGeol
                    openCite(xmlTempSubDoc, oCite, bCheck2)
                    If (bCheck2 = True) Then
                        f11.bCitationLWork = True
                        f11.objCitationLWork = oCite 'update public larger work citation object with current LWC info
                    End If
                End If 'end processing of larger work citation
                'fill the form controls
                f11.txtIDCiteAuth.Text = f11.objCitation.Author
                f11.txtIDCiteDate.Text = f11.objCitation.PubDate
                f11.txtIDCiteTitle.Text = f11.objCitation.Title
            End If 'end processing of citation
        End If


        'open Description
        xmlNList = xmlOpenID.SelectNodes("/idinfo/descript")
        If (xmlNList.Count > 0) Then
            'get Description node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/descript").OuterXml
        Else
            sIDinfo = ""
        End If

        If (sIDinfo <> "") Then
            xmlTempDoc.LoadXml(sIDinfo) 'load the Description node
            'retrieve Abstract
            xmlNList = xmlTempDoc.SelectNodes("/descript/abstract")
            If (xmlNList.Count > 0) Then
                sIDinfo = xmlTempDoc.SelectSingleNode("/descript/abstract").InnerText
                If (sIDinfo <> "") Then f11.txtAbstract.Text = sIDinfo
            End If
            'retrieve Purpose
            xmlNList = xmlTempDoc.SelectNodes("/descript/purpose")
            If (xmlNList.Count > 0) Then
                sIDinfo = xmlTempDoc.SelectSingleNode("/descript/purpose").InnerText
                If (sIDinfo <> "") Then f11.txtPurpose.Text = sIDinfo
            End If
            'retrieve Supplemental Info
            xmlNList = xmlTempDoc.SelectNodes("/descript/supplinf")
            If (xmlNList.Count > 0) Then
                sIDinfo = xmlTempDoc.SelectSingleNode("/descript/supplinf").InnerText
                If (sIDinfo <> "") Then f11.txtSupplInfo.Text = sIDinfo
            End If
        End If


        'open Time Period of Content
        xmlNList = xmlOpenID.SelectNodes("/idinfo/timeperd")
        If (xmlNList.Count > 0) Then
            'get Time Period of Content node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/timeperd").OuterXml
            openIDtime(sIDinfo)
        End If

        'open Status
        xmlNList = xmlOpenID.SelectNodes("/idinfo/status")
        If (xmlNList.Count > 0) Then
            'get Status node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/status").OuterXml
        Else
            sIDinfo = ""
        End If

        If (sIDinfo <> "") Then
            xmlTempDoc.LoadXml(sIDinfo)
            'retrieve Progress
            xmlNList = xmlTempDoc.SelectNodes("/status/progress")
            If (xmlNList.Count > 0) Then
                sIDinfo = xmlTempDoc.SelectSingleNode("/status/progress").InnerText
                If (sIDinfo <> "") Then
                    iSelInd = f11.lboxProg.FindString(sIDinfo)
                    f11.lboxProg.SelectedIndex = iSelInd
                End If
            End If
            'retrieve Update Frequency, set the combo box
            xmlNList = xmlTempDoc.SelectNodes("/status/update")
            If (xmlNList.Count > 0) Then
                sIDinfo = xmlTempDoc.SelectSingleNode("/status/update").InnerText
                If (sIDinfo <> "") Then
                    iSelInd = f11.cboxUpdate.FindStringExact(sIDinfo)
                    If (iSelInd = -1) Then
                        'a free text element
                        f11.cboxUpdate.Items.Add(sIDinfo)
                        f11.cboxUpdate.SelectedIndex = f11.cboxUpdate.Items.Count - 1
                    Else
                        f11.cboxUpdate.SelectedIndex = iSelInd
                    End If
                End If
            End If
        End If


        'open Spatial Domain
        xmlNList = xmlOpenID.SelectNodes("/idinfo/spdom")
        If (xmlNList.Count > 0) Then
            'get Spatial Domain node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/spdom").OuterXml
            openIDspdom(sIDinfo)
        End If

        'open Keywords
        xmlNList = xmlOpenID.SelectNodes("/idinfo/keywords")
        If (xmlNList.Count > 0) Then
            'get Keywords node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/keywords").OuterXml
            openIDkeywords(sIDinfo)
        End If

        'open Taxonomy
        xmlNList = xmlOpenID.SelectNodes("/idinfo/taxonomy")
        If (xmlNList.Count > 0) Then
            'get Taxonomy node
            sIDinfo = xmlOpenID.SelectSingleNode("/idinfo/taxonomy").OuterXml
            openIDtaxonomy(sIDinfo)
        End If

        'open Access Constraints
        xmlNList = xmlOpenID.SelectNodes("/idinfo/accconst")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).InnerText.Trim
            f15.txtIDaccess.Text = sIDinfo
        End If

        'open Use Constraints
        xmlNList = xmlOpenID.SelectNodes("/idinfo/useconst")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).InnerText.Trim
            f15.txtIDuse.Text = sIDinfo
        End If

        'open Point of Contact
        xmlNList = xmlOpenID.SelectNodes("/idinfo/ptcontac")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).InnerXml
            openContact(sIDinfo, oNewContact)
            f15.objDataContact = oNewContact 'update the contact object
            If (f15.objDataContact.PrimaryPerson = True) Then 'update the form display
                f15.txtDataContact.Text = f15.objDataContact.Person
            Else
                f15.txtDataContact.Text = f15.objDataContact.Organization
            End If
        End If

        'open Browse Graphic(s), if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/browse")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sIDinfo = xmlNList(iLoop).OuterXml
            openIDgraphic(sIDinfo)
        Next

        'open Data Set Credit, if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/datacred")
        If (xmlNList.Count > 0) Then
            f17.txtDScredit.Text = xmlNList(0).InnerText.Trim
        End If

        'open Security Information, if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/secinfo")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).OuterXml
            openIDsecurity(sIDinfo)
        End If

        'open Native Data Set Environment, if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/native")
        If (xmlNList.Count > 0) Then
            f17.txtDSenviron.Text = xmlNList(0).InnerText.Trim
        End If

        'open Cross Reference(s), if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/crossref")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sIDinfo = xmlNList(iLoop).OuterXml
            openIDxref(sIDinfo)
        Next

        'open Analytical Tool(s), if present
        xmlNList = xmlOpenID.SelectNodes("/idinfo/tool")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sIDinfo = xmlNList(iLoop).OuterXml
            openIDtool(sIDinfo)
        Next

    End Sub

    Private Sub openIDtime(ByVal sTimeInfo As String)
        Dim xmlTempDoc As New XmlDocument
        Dim xmlTimeDoc As New XmlDocument 'will handle Time Info sub-section
        Dim xmlNList As XmlNodeList
        Dim oCite As New CiteInfo 'for Citation
        Dim oSource As New SourceClass 'for Time Info
        Dim cIDTimeColl As New Collection 'for Time Info
        Dim s1 As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlTempDoc.LoadXml(sTimeInfo) 'node exists, fill local DOM

        'retrieve Time Period Information
        xmlNList = xmlTempDoc.SelectNodes("/timeperd/timeinfo")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlTempDoc.SelectSingleNode("/timeperd/timeinfo").OuterXml
            xmlTimeDoc.LoadXml(sIDinfo)
            openTimeInfo(xmlTimeDoc, oSource, cIDTimeColl) 'process the time info nodes

            'load returned information into collection and form
            If (oSource.Gregorian = True) Then
                f11.rdoTLocal.Checked = True
            Else
                f11.rdoTGeol.Checked = True
            End If
            If (oSource.boolSingle = True And oSource.boolRange = True) Then
                f11.rdoTUnknown.Checked = True
            ElseIf (oSource.boolSingle = True And oSource.boolRange = False) Then
                f11.rdoTSingle.Checked = True
            ElseIf (oSource.boolSingle = False And oSource.boolRange = True) Then
                f11.rdoTRange.Checked = True
            Else
                f11.rdoTMult.Checked = True
            End If
            f11.IDtimeper = cIDTimeColl 'copy date/time collection to public collection

            'fill the list box with date/time identifiers
            iCount = f11.IDtimeper.Count

            Dim strNewDate As String = ""
            If (f11.rdoTLocal.Checked = True) Then  'process Gregorian dates
                Dim dBegin As New SngDateTime
                Dim dEnding As New SngDateTime
                If (f11.rdoTUnknown.Checked = True) Then
                    f11.IDtimeper = New Collection
                End If
                If (f11.rdoTRange.Checked = False) Then  'add the date/time(s) to list box
                    For iLoop = 1 To iCount
                        dBegin = CType(f11.IDtimeper(iLoop), SngDateTime)
                        strNewDate = dBegin.SngDate & "  " & dBegin.TimeOfDay
                        f11.lboxTime.Items.Add(strNewDate)
                    Next
                Else     'add date/time range to list box
                    dBegin = CType(f11.IDtimeper(1), SngDateTime)
                    dEnding = CType(f11.IDtimeper(2), SngDateTime)
                    strNewDate = "begin: " & dBegin.SngDate & "  " & "end: " & dEnding.SngDate
                    f11.lboxTime.Items.Add(strNewDate)
                End If
            Else                              'process Geologic Age dates
                Dim dBegin As New GeolAge
                Dim dEnding As New GeolAge
                If (f11.rdoTUnknown.Checked = True) Then
                    f11.IDtimeper = New Collection
                End If
                If (f11.rdoTRange.Checked = False) Then  'add Geologic Age(s) to list box
                    For iLoop = 1 To iCount
                        dBegin = CType(f11.IDtimeper(iLoop), GeolAge)
                        strNewDate = dBegin.TimeScale & "  " & dBegin.Estim
                        f11.lboxTime.Items.Add(strNewDate)
                    Next
                Else     'add and update Geologic Age range
                    dBegin = CType(f11.IDtimeper(1), GeolAge)
                    dEnding = CType(f11.IDtimeper(2), GeolAge)
                    strNewDate = "begin: " & dBegin.Estim & "  " & "end: " & dEnding.Estim
                    f11.lboxTime.Items.Add(strNewDate)
                End If
            End If
        End If

        'retrieve Currentness Reference, set the combo box
        xmlNList = xmlTempDoc.SelectNodes("/timeperd/current")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlTempDoc.SelectSingleNode("/timeperd/current").InnerText
            If (sIDinfo <> "") Then
                iSelInd = f11.cboxCurRef.FindStringExact(sIDinfo)
                If (iSelInd = -1) Then
                    'a free text element
                    f11.cboxCurRef.Items.Add(sIDinfo)
                    f11.cboxCurRef.SelectedIndex = f11.cboxCurRef.Items.Count - 1
                Else
                    f11.cboxCurRef.SelectedIndex = iSelInd
                End If
            End If
        End If


    End Sub

    Private Sub openIDspdom(ByVal sSpaDom As String)
        Dim xmlTempDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim dValue As Decimal = 0

        xmlTempDoc.LoadXml(sSpaDom) 'node exists, fill local DOM

        'retrieve Geographic Extent
        xmlNList = xmlTempDoc.SelectNodes("/spdom/descgeog")
        If (xmlNList.Count > 0) Then f12.txtGeoExt.Text = xmlNList(0).InnerText

        'retrieve Bounding Coordinates
        xmlNList = xmlTempDoc.SelectNodes("/spdom/bounding")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            xmlNList = xmlTempDoc.SelectNodes("spdom/bounding/westbc") 'the West Bounding Coordinate
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "West Bounding Coordinate of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Coordinate input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                adjLongitude(dValue, "W")
                f12.numWestBC.Value = dValue
            End If
            xmlNList = xmlTempDoc.SelectNodes("spdom/bounding/eastbc") 'the East Bounding Coordinate
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "East Bounding Coordinate of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Coordinate input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                adjLongitude(dValue, "E")
                f12.numEastBC.Value = dValue
            End If
            xmlNList = xmlTempDoc.SelectNodes("spdom/bounding/northbc") 'the North Bounding Coordinate
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "North Bounding Coordinate of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Coordinate input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                adjLatitude(dValue)
                f12.numNorthBC.Value = dValue
            End If
            xmlNList = xmlTempDoc.SelectNodes("spdom/bounding/southbc") 'the South Bounding Coordinate
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "South Bounding Coordinate of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Coordinate input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                adjLatitude(dValue)
                f12.numSouthBC.Value = dValue
            End If
        End If

        'Bounding Altitudes, if present
        xmlNList = xmlTempDoc.SelectNodes("/spdom/bounding/boundalt")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            xmlNList = xmlTempDoc.SelectNodes("/spdom/bounding/boundalt/altmin") 'Altitude Minimum
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "Altitude Minimum of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Altitude input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                'check against bounds of numeric control
                If (dValue > 1000000) Then
                    dValue = 1000000
                ElseIf (dValue < -1000000) Then
                    dValue = -1000000
                End If
                f12.numAltMin.Value = dValue
            End If

            xmlNList = xmlTempDoc.SelectNodes("/spdom/bounding/boundalt/altmax") 'Altitude Maximum
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                Try
                    dValue = Convert.ToDecimal(s1)
                Catch ex As Exception
                    sError = "Altitude Maximum of " & s1 & " is not a number"
                    MessageBox.Show(sError, "Bounding Altitude input error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    dValue = 0
                End Try
                'check against bounds of numeric control
                If (dValue > 1000000) Then
                    dValue = 1000000
                ElseIf (dValue < -1000000) Then
                    dValue = -1000000
                End If
                f12.numAltMax.Value = dValue
            End If

            xmlNList = xmlTempDoc.SelectNodes("/spdom/bounding/boundalt/altunits") 'Altitude Distance Units
            If (xmlNList.Count > 0) Then
                s1 = xmlNList(0).InnerText
                iSelInd = f12.cboxIDaltDistU.FindStringExact(s1)
                If (iSelInd = -1 And s1 <> "") Then
                    'add the distance units entry
                    f12.cboxIDaltDistU.Items.Add(s1)
                    f12.cboxIDaltDistU.SelectedIndex = f12.cboxIDaltDistU.Items.Count - 1
                ElseIf (iSelInd > -1) Then
                    f12.cboxIDaltDistU.SelectedIndex = iSelInd
                End If
            End If
        End If


        'Data Set G-Polygons, if present
        Dim s2 As String = ""
        Dim xmlPlist As XmlNodeList
        Dim iGRing As Integer = 0
        Dim iExCount As Integer = 0
        Dim iLoopEx As Integer = 0
        xmlNList = xmlTempDoc.SelectNodes("/spdom/dsgpoly") 'node list of G-Polygons
        iCount = xmlNList.Count - 1 'working with 0-based string collections
        For iLoop = 0 To iCount
            xmlPlist = xmlNList(iLoop).SelectNodes("dsgpolyo")
            s2 = ""
            iGRing = 0
            If (xmlPlist.Count > 0) Then
                iGRing = 1
                sIDinfo = xmlNList(iLoop).SelectSingleNode("dsgpolyo").OuterXml
                procGRing(s2, sIDinfo, "outer")
                If (s2 = "") Then iGRing = 0
            End If

            If (iGRing > 0) Then
                'process Exclusion G-Rings
                xmlPlist = xmlNList(iLoop).SelectNodes("dsgpolyx") 'node list of Exclusion G-Rings
                iExCount = xmlPlist.Count
                For iLoopEx = 0 To iExCount - 1 'adjust for 0-based index in processing
                    sIDinfo = xmlPlist(iLoopEx).OuterXml
                    s2 = ""
                    procGRing(s2, sIDinfo, "exclude")
                    If (s2 = "") Then iExCount -= 1
                Next
                f12.sCountGPoly.Add(iExCount.ToString) 'number of exclusion polygons associated with the G-Polygon
            End If
        Next

    End Sub

    Private Sub adjLongitude(ByRef dValue As Decimal, ByVal sDirect As String)
        'routine checks longitude bounds on dValue, adjusts as needed
        'normally, sDirect will be "W"
        Dim sError As String = ""
        If (dValue > 180.0) Then
            sError = "Longitude of " & dValue.ToString & " is being set to 179.99999"
            MessageBox.Show(sError, "Longitude out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Error)
            dValue = 179.99999D
        End If
        If (dValue = 180.0 And sDirect = "W") Then 'west bounding coordinate fix
            sError = "Longitude of " & dValue.ToString & " is being set to 179.99999"
            MessageBox.Show(sError, "Longitude out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Error)
            dValue = 179.99999D
        End If
        If (dValue < -180.0) Then
            sError = "Longitude of " & dValue.ToString & " is being set to -180.0"
            MessageBox.Show(sError, "Longitude out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Error)
            dValue = -180D
        End If
    End Sub

    Private Sub adjLatitude(ByRef dValue As Decimal)
        'routine checks latitude bounds on dValue, adjusts as needed
        Dim sError As String = ""
        If (dValue > 90.0) Then
            sError = "Latitude of " & dValue.ToString & " is being set to 179.99999"
            MessageBox.Show(sError, "Latitude out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Error)
            dValue = 180D
        End If
        If (dValue < -90.0) Then
            sError = "Latitude of " & dValue.ToString & " is being set to -180.0"
            MessageBox.Show(sError, "Latitude out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Error)
            dValue = -180D
        End If
    End Sub

    Private Sub procGRing(ByRef s2 As String, ByVal sNode As String, ByVal sType As String)
        'process Data Set G-Polygon information
        'sType is either "outer" or "exclude"
        Dim xmlRingDoc As New XmlDocument
        Dim xmlPlist As XmlNodeList
        Dim xmlRlist As XmlNodeList
        Dim s1 As String = ""
        Dim sLat As String = ""
        Dim sLong As String = ""
        Dim dLat As Decimal = 0
        Dim dLong As Decimal = 0
        Dim sList As String = ""
        Dim iGPoint As Integer = 0
        Dim iGRing As Integer = 0
        Dim iLoop As Integer = 0

        s1 = ""
        s2 = ""
        xmlRingDoc.LoadXml(sNode)

        'look for and process G-Rings
        If (sType = "outer") Then
            xmlPlist = xmlRingDoc.SelectNodes("dsgpolyo/gring")
        Else
            xmlPlist = xmlRingDoc.SelectNodes("dsgpolyx/gring")
        End If
        iGRing = xmlPlist.Count
        If (iGRing > 0) Then
            'process the outer G-Ring string
            'if have G-Ring string, then do not process G-Ring points even if present
            s1 = "string"
            s2 = xmlPlist(0).InnerText
            s2 = s2.Trim
            If (s2 = "") Then
                'blank G-Ring strings are ignored
                iGRing = 0
            Else
                f12.sDataSetGPoly.Add(s1)
                f12.sDataSetGPoly.Add(s2)
                If (sType = "outer") Then
                    sList = s1 & ": " & Microsoft.VisualBasic.Left(s2, 32)
                    sList = sList.Replace(sPdelim, "  ")
                    f12.lboxGPoly.Items.Add(sList) 'add data set polygon to list box (outer g-ring)
                End If
                Return 'nontrivial G-Ring found and processed
            End If
        End If


        'look for and process G-Ring Points
        If (sType = "outer") Then
            xmlPlist = xmlRingDoc.SelectNodes("dsgpolyo/grngpoin")
        Else
            xmlPlist = xmlRingDoc.SelectNodes("dsgpolyx/grngpoin")
        End If

        iGPoint = xmlPlist.Count
        s2 = ""

        If (iGPoint > 0) Then
            'process the G-Ring points
            s1 = "points"
            For iLoop = 0 To iGPoint - 1
                sLat = ""
                sLong = ""
                xmlRlist = xmlPlist(iLoop).SelectNodes("gringlat")
                If (xmlRlist.Count > 0) Then
                    sLat = xmlRlist(0).InnerText
                    Try
                        dLat = Convert.ToDecimal(sLat)
                        'make sure the value is a number
                    Catch ex As Exception
                        sLat = ""
                    End Try
                    If (sLat <> "") Then
                        'check bounds
                        adjLatitude(dLat)
                        sLat = dLat.ToString
                    End If
                End If

                xmlRlist = xmlPlist(iLoop).SelectNodes("gringlon")
                If (xmlRlist.Count > 0) Then
                    sLong = xmlRlist(0).InnerText
                    Try
                        dLong = Convert.ToDecimal(sLong)
                        'make sure the value is a number
                    Catch ex As Exception
                        sLong = ""
                    End Try
                    If (sLong <> "") Then
                        'check bounds
                        adjLongitude(dLong, "W")
                        sLong = dLong.ToString
                    End If
                End If
                If (sLat <> "" And sLong <> "") Then
                    s2 += sLat & " " & sLong & sPdelim
                End If
            Next
            If (s2 <> "") Then s2 = s2.Substring(0, s2.Length - 1)
        End If

        If (s2 = "") Then
            'blank G-Ring points are ignored
        Else
            f12.sDataSetGPoly.Add(s1)
            f12.sDataSetGPoly.Add(s2)
            If (sType = "outer") Then
                sList = s1 & ": " & Microsoft.VisualBasic.Left(s2, 32)
                sList = sList.Replace(sPdelim, "  ")
                f12.lboxGPoly.Items.Add(sList) 'add data set polygon to list box (outer g-ring)
            End If
        End If
    End Sub

    Private Sub openIDkeywords(ByVal sKeywords As String)
        Dim xmlKeyDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sThesaurus As String = ""
        Dim sKey As String = ""
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sKeyArray() As String
        Dim sList As String

        xmlKeyDoc.LoadXml(sKeywords) 'node exists, fill local DOM

        'retrieve Themes
        xmlNList = xmlKeyDoc.SelectNodes("/keywords/theme")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'process Themes
            For iLoop = 0 To iCount - 1
                sThesaurus = ""
                xmlPlist = xmlNList(iLoop).SelectNodes("themekt")
                If (xmlPlist.Count > 0) Then
                    sThesaurus = xmlPlist(0).InnerText
                End If
                xmlPlist = xmlNList(iLoop).SelectNodes("themekey")
                If (xmlPlist.Count > 0) Then
                    'process keywords
                    kCount = xmlPlist.Count
                    sKey = ""
                    For kLoop = 0 To kCount - 1
                        s1 = xmlPlist(kLoop).InnerText
                        s1 = s1.Trim
                        If (s1 <> "") Then
                            sKey += s1 & sKdelim
                        End If
                    Next
                End If
                If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
                If (sKey = "" Or sThesaurus = "") Then
                    'do nothing, incomplete information considered error condition
                Else
                    sList = "thesaurus: " & sThesaurus & "   keywords: " & sKey
                    sList = sList.Replace(sKdelim, "; ")
                    f13.lboxKTheme.Items.Add(sList) 'add formatted info to listbox
                    sThesaurus += sPdelim & sKey
                    f13.sKeyTheme.Add(sThesaurus) 'add theme keyword info to collection
                End If
            Next
        End If

        'retrieve Places
        xmlNList = xmlKeyDoc.SelectNodes("/keywords/place")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'process Places
            For iLoop = 0 To iCount - 1
                sThesaurus = ""
                xmlPlist = xmlNList(iLoop).SelectNodes("placekt")
                If (xmlPlist.Count > 0) Then
                    sThesaurus = xmlPlist(0).InnerText
                End If
                xmlPlist = xmlNList(iLoop).SelectNodes("placekey")
                If (xmlPlist.Count > 0) Then
                    'process keywords
                    kCount = xmlPlist.Count
                    sKey = ""
                    For kLoop = 0 To kCount - 1
                        s1 = xmlPlist(kLoop).InnerText
                        s1 = s1.Trim
                        If (s1 <> "") Then
                            sKey += s1 & sKdelim
                        End If
                    Next
                End If
                If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
                If (sKey = "" Or sThesaurus = "") Then
                    'do nothing, incomplete information considered error condition
                Else
                    sList = "thesaurus: " & sThesaurus & "   keywords: " & sKey
                    sList = sList.Replace(sKdelim, "; ")
                    f13.lboxKPlace.Items.Add(sList) 'add formatted info to listbox
                    sThesaurus += sPdelim & sKey
                    f13.sKeyPlace.Add(sThesaurus) 'add place keyword info to collection
                End If
            Next
        End If

        'retrieve Strata
        xmlNList = xmlKeyDoc.SelectNodes("/keywords/stratum")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'process Strata
            For iLoop = 0 To iCount - 1
                sThesaurus = ""
                xmlPlist = xmlNList(iLoop).SelectNodes("stratkt")
                If (xmlPlist.Count > 0) Then
                    sThesaurus = xmlPlist(0).InnerText
                End If
                xmlPlist = xmlNList(iLoop).SelectNodes("stratkey")
                If (xmlPlist.Count > 0) Then
                    'process keywords
                    kCount = xmlPlist.Count
                    sKey = ""
                    For kLoop = 0 To kCount - 1
                        s1 = xmlPlist(kLoop).InnerText
                        s1 = s1.Trim
                        If (s1 <> "") Then
                            sKey += s1 & sKdelim
                        End If
                    Next
                End If
                If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
                If (sKey = "" Or sThesaurus = "") Then
                    'do nothing, incomplete information considered error condition
                Else
                    sList = "thesaurus: " & sThesaurus & "   keywords: " & sKey
                    sList = sList.Replace(sKdelim, "; ")
                    f13.lboxKStratum.Items.Add(sList) 'add formatted info to listbox
                    sThesaurus += sPdelim & sKey
                    f13.sKeyStratum.Add(sThesaurus) 'add stratum keyword info to collection
                End If
            Next
        End If

        'retrieve Temporal
        xmlNList = xmlKeyDoc.SelectNodes("/keywords/temporal")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'process Themes
            For iLoop = 0 To iCount - 1
                sThesaurus = ""
                xmlPlist = xmlNList(iLoop).SelectNodes("tempkt")
                If (xmlPlist.Count > 0) Then
                    sThesaurus = xmlPlist(0).InnerText
                End If
                xmlPlist = xmlNList(iLoop).SelectNodes("tempkey")
                If (xmlPlist.Count > 0) Then
                    'process keywords
                    kCount = xmlPlist.Count
                    sKey = ""
                    For kLoop = 0 To kCount - 1
                        s1 = xmlPlist(kLoop).InnerText
                        s1 = s1.Trim
                        If (s1 <> "") Then
                            sKey += s1 & sKdelim
                        End If
                    Next
                End If
                If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
                If (sKey = "" Or sThesaurus = "") Then
                    'do nothing, incomplete information considered error condition
                Else
                    sList = "thesaurus: " & sThesaurus & "   keywords: " & sKey
                    sList = sList.Replace(sKdelim, "; ")
                    f13.lboxKTemporal.Items.Add(sList) 'add formatted info to listbox
                    sThesaurus += sPdelim & sKey
                    f13.sKeyTemporal.Add(sThesaurus) 'add temporal keyword info to collection
                End If
            Next
        End If
    End Sub

    Private Sub openIDtaxonomy(ByVal sTaxa As String)
        Dim xmlTaxaDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sThesaurus As String = ""
        Dim sKey As String = ""
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sKeyArray() As String
        Dim sList As String

        xmlTaxaDoc.LoadXml(sTaxa) 'node exists, fill local DOM

        'retrieve Keywords/Taxon
        xmlNList = xmlTaxaDoc.SelectNodes("/taxonomy/keywtax")
        iCount = xmlNList.Count
        If (iCount > 0) Then
            'process Keywords/Taxon
            For iLoop = 0 To iCount - 1
                sThesaurus = ""
                xmlPlist = xmlNList(iLoop).SelectNodes("taxonkt")
                If (xmlPlist.Count > 0) Then
                    sThesaurus = xmlPlist(0).InnerText
                End If
                xmlPlist = xmlNList(iLoop).SelectNodes("taxonkey")
                If (xmlPlist.Count > 0) Then
                    'process keywords
                    kCount = xmlPlist.Count
                    sKey = ""
                    For kLoop = 0 To kCount - 1
                        s1 = xmlPlist(kLoop).InnerText
                        s1 = s1.Trim
                        If (s1 <> "") Then
                            sKey += s1 & sKdelim
                        End If
                    Next
                End If
                If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
                If (sKey = "" Or sThesaurus = "") Then
                    'do nothing, incomplete information considered error condition
                Else
                    sList = sThesaurus & ":  " & sKey
                    sList = sList.Replace(sKdelim, "; ")
                    f14.lboxTaxKey.Items.Add(sList) 'add formatted info to listbox
                    sThesaurus += sPdelim & sKey
                    f14.sTaxKeywords.Add(sThesaurus) 'add taxon keyword info to collection
                End If
            Next
        End If

        'open Taxonomic System
        xmlNList = xmlTaxaDoc.SelectNodes("/taxonomy/taxonsys")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).OuterXml
            openIDtaxsys(sIDinfo)
        End If

        'retrieve Taxonomic Coverage, if present
        xmlNList = xmlTaxaDoc.SelectNodes("/taxonomy/taxongen")
        If (xmlNList.Count > 0) Then
            s1 = xmlNList(0).InnerText
            s1 = s1.Trim
            f14.txtTaxCover.Text = s1
        End If

        'retrieve Taxonomic Classification
        ' 1. build the TaxaClasses collection
        xmlNList = xmlTaxaDoc.SelectNodes("/taxonomy/taxoncl")
        If (xmlNList.Count > 0) Then
            sIDinfo = xmlNList(0).OuterXml
            f14.xmlTaxonClass.LoadXml(sIDinfo)
            openIDtaxclass(sIDinfo)
        End If

        ' 2. create the display
        f14.lboxLinneausBuild()
    End Sub

    Private Sub openIDtaxsys(ByVal sTaxSys As String)
        Dim xmlTaxSysDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sClassMod As String = ""
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sIDinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sList As String
        Dim xmlCiteDoc As New XmlDocument
        Dim bCheck As Boolean = False
        Dim oCite As New CiteInfo
        Dim bLWC As Boolean = False
        Dim oCiteLWC As New CiteInfo
        Dim oContact As New ContactInfo

        xmlTaxSysDoc.LoadXml(sTaxSys) 'node exists, fill local DOM

        'retrieve Classification System or Authority
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/classsys")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            oCite = New CiteInfo
            bLWC = False
            oCiteLWC = New CiteInfo

            'retrieve Citation
            xmlPlist = xmlNList(iLoop).SelectNodes("classcit/citeinfo")
            kCount = xmlPlist.Count
            If (kCount > 0) Then
                'process Citation
                sIDinfo = xmlPlist(0).OuterXml
                xmlCiteDoc.LoadXml(sIDinfo)
                openCite(xmlCiteDoc, oCite, bCheck) 'main citation
                If (bCheck = False) Then
                    'no required citation elements found
                Else
                    sList = "cite: " & oCite.Author & " — " & oCite.Title
                    f14.lboxTaxSys.Items.Add(sList) 'put citation ID into list box
                    'look for Larger Work Citation
                    xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                    bCheck = False
                    If (xmlPlist.Count > 0) Then
                        sIDinfo = xmlPlist(0).OuterXml
                        xmlCiteDoc.LoadXml(sIDinfo)
                        openCite(xmlCiteDoc, oCiteLWC, bCheck) 'larger work citation
                    End If
                    If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed

                    'process Classification System Modifications, if present
                    sClassMod = ""
                    xmlPlist = xmlNList(iLoop).SelectNodes("classmod")
                    If (xmlPlist.Count > 0) Then
                        sClassMod = xmlPlist(0).InnerText
                    End If
                    sList = "  modifications: " & Microsoft.VisualBasic.Left(sClassMod, 50)
                    f14.lboxTaxSys.Items.Add(sList) 'put mods into list box

                    'update the main collections
                    f14.citeTaxSys.Add(oCite)
                    f14.boolTaxSys.Add(bLWC)
                    f14.citeTaxSysLWC.Add(oCiteLWC)
                    f14.sTaxSysMods.Add(sClassMod) 'might be blank string
                End If
            End If
        Next


        'retrieve Identification Reference(s)
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/idref")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            oCite = New CiteInfo
            bLWC = False
            oCiteLWC = New CiteInfo

            'retrieve IDref Citation
            xmlPlist = xmlNList(iLoop).SelectNodes("citeinfo")
            kCount = xmlPlist.Count
            If (kCount > 0) Then
                'process Citation
                sIDinfo = xmlPlist(0).OuterXml
                xmlCiteDoc.LoadXml(sIDinfo)
                openCite(xmlCiteDoc, oCite, bCheck) 'main citation
                If (bCheck = False) Then
                    'no required citation elements found
                Else
                    sList = "cite: " & oCite.Author & " — " & oCite.Title
                    f14.lboxTaxIDRef.Items.Add(sList) 'put citation ID into list box
                    'look for Larger Work Citation
                    xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                    bCheck = False
                    If (xmlPlist.Count > 0) Then
                        sIDinfo = xmlPlist(0).OuterXml
                        xmlCiteDoc.LoadXml(sIDinfo)
                        openCite(xmlCiteDoc, oCiteLWC, bCheck) 'main citation
                    End If
                    If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed

                    'update the main collections
                    f14.citeTaxIDRef.Add(oCite)
                    f14.boolTaxIDRef.Add(bLWC)
                    f14.citeTaxIDRefLWC.Add(oCiteLWC)
                End If
            End If
        Next


        'retrieve Identifier(s)
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/ider")
        iCount = xmlNList.Count - 1
        For iLoop = 0 To iCount
            xmlPlist = xmlNList(iLoop).SelectNodes("cntinfo")
            If (xmlPlist.Count > 0) Then
                'get the Contact Information XML
                sIDinfo = xmlPlist(0).OuterXml
                openContact(sIDinfo, oContact)
                'put into main collection and display
                f14.cntTaxID.Add(oContact)
                If (oContact.PrimaryPerson = True) Then
                    f14.lboxTaxID.Items.Add(oContact.Person)
                Else
                    f14.lboxTaxID.Items.Add(oContact.Organization)
                End If
            End If
        Next


        'retrieve Taxonomic Procedures
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/taxonpro")
        If (xmlNList.Count > 0) Then
            sClassMod = xmlNList(0).InnerText
            sClassMod = sClassMod.Trim
            f14.txtTaxProc.Text = sClassMod
        End If


        'retrieve Taxonomic Completeness
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/taxoncom")
        If (xmlNList.Count > 0) Then
            sClassMod = xmlNList(0).InnerText
            sClassMod = sClassMod.Trim
            f14.txtTaxComplete.Text = sClassMod
        End If


        'retrieve Vouchers
        xmlNList = xmlTaxSysDoc.SelectNodes("/taxonsys/vouchers")
        iCount = xmlNList.Count - 1
        For iLoop = 0 To iCount
            xmlPlist = xmlNList(iLoop).SelectNodes("specimen") 'retrieve specimen
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                f14.sVSpecimen.Add(s1)
                sList = "specimen: " & Microsoft.VisualBasic.Left(s1, 50)
                f14.lboxVouchers.Items.Add(sList)
            End If
            xmlPlist = xmlNList(iLoop).SelectNodes("reposit/cntinfo") 'retrieve repository
            If (xmlPlist.Count > 0) Then
                'get the Contact Information XML
                sIDinfo = xmlPlist(0).OuterXml
                openContact(sIDinfo, oContact)
                'put into main collection and display
                f14.cntVouchers.Add(oContact)
                If (oContact.PrimaryPerson = True) Then
                    sList = "  repository: " & oContact.Person
                Else
                    sList = "  repository: " & oContact.Organization
                End If
                f14.lboxVouchers.Items.Add(sList)
            End If
        Next
    End Sub

    Private Sub openIDtaxclass(ByVal sTaxClass As String)
        Dim xmlTaxClassDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim s1 As String = ""
        Dim sIDinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim iLevel As Integer = 0
        Dim oNewTaxa As New TaxonClass

        xmlTaxClassDoc.LoadXml(sTaxClass) 'node exists, fill local DOM
        oNewTaxa = New TaxonClass

        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxonrn")
        If (xmlNList.Count > 0) Then 'get rank name
            oNewTaxa.RankName = xmlNList(0).InnerText.Trim
        End If
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxonrv")
        If (xmlNList.Count > 0) Then 'get rank value
            oNewTaxa.RankValue = xmlNList(0).InnerText.Trim
        End If
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/common")
        iCount = xmlNList.Count - 1
        s1 = ""
        For iLoop = 0 To iCount
            'process common names
            s1 = xmlNList(iLoop).InnerText.Trim & sKdelim
        Next
        oNewTaxa.CommonName = s1

        'set base level to zero
        iLevel = 0
        oNewTaxa.Level = iLevel

        'process additional taxonomic classification nodes
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxoncl")
        iCount = xmlNList.Count
        oNewTaxa.Nchildren = iCount
        f14.TaxaClasses.Add(oNewTaxa) 'add node to main collection
        iLevel += 1
        For iLoop = 0 To iCount - 1
            sIDinfo = xmlNList(iLoop).OuterXml
            openIDtaxon(sIDinfo, iLevel)
        Next

    End Sub

    Private Sub openIDtaxon(ByVal sTaxon As String, ByVal iLevel As Integer)
        'sTaxon contains an XML string, iLevel is the current level
        Dim xmlTaxClassDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim s1 As String = ""
        Dim sIDinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim oNewTaxa As New TaxonClass

        xmlTaxClassDoc.LoadXml(sTaxon) 'node exists, fill local DOM
        oNewTaxa = New TaxonClass

        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxonrn")
        If (xmlNList.Count > 0) Then 'get rank name
            oNewTaxa.RankName = xmlNList(0).InnerText.Trim
        End If
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxonrv")
        If (xmlNList.Count > 0) Then 'get rank value
            oNewTaxa.RankValue = xmlNList(0).InnerText.Trim
        End If
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/common")
        iCount = xmlNList.Count - 1
        s1 = ""
        For iLoop = 0 To iCount
            'process common names
            s1 = s1 & xmlNList(iLoop).InnerText.Trim & sKdelim
        Next
        oNewTaxa.CommonName = s1

        'set current node's level
        oNewTaxa.Level = iLevel

        'process additional taxonomic classification nodes
        xmlNList = xmlTaxClassDoc.SelectNodes("/taxoncl/taxoncl")
        iCount = xmlNList.Count
        oNewTaxa.Nchildren = iCount
        f14.TaxaClasses.Add(oNewTaxa) 'add node to main collection
        iLevel += 1
        For iLoop = 0 To iCount - 1
            sIDinfo = xmlNList(iLoop).OuterXml
            openIDtaxon(sIDinfo, iLevel)
        Next
    End Sub

    Private Sub openIDgraphic(ByVal sGraphic As String)
        Dim xmlGraphicDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim sName As String = ""
        Dim sDesc As String = ""
        Dim sType As String = ""
        Dim bEmpty As Boolean = True 'the graphic lacks all 3 required elements
        Dim sList As String

        xmlGraphicDoc.LoadXml(sGraphic) 'node exists, fill local DOM
        sName = ""
        sDesc = ""
        sType = ""
        bEmpty = True

        'retrieve File Name
        xmlNList = xmlGraphicDoc.SelectNodes("/browse/browsen")
        If (xmlNList.Count > 0) Then
            sName = xmlNList(0).InnerText.Trim
            If (sName <> "") Then bEmpty = False
        End If

        'retrieve File Description
        xmlNList = xmlGraphicDoc.SelectNodes("/browse/browsed")
        If (xmlNList.Count > 0) Then
            sDesc = xmlNList(0).InnerText.Trim
            If (sDesc <> "") Then bEmpty = False
        End If

        'retrieve File Type
        xmlNList = xmlGraphicDoc.SelectNodes("/browse/browset")
        If (xmlNList.Count > 0) Then
            sType = xmlNList(0).InnerText.Trim
            If (sType <> "") Then bEmpty = False
        End If

        If (bEmpty = False) Then
            'update list box display
            sList = sName & "    " & sDesc
            f17.lboxBrGraphic.Items.Add(sList)
            'update main string collection
            sList = sName & sPdelim & sDesc & sPdelim & sType
            f17.sBrowseGraphics.Add(sList)
        End If
        Return
    End Sub

    Private Sub openIDsecurity(ByVal sSecurity As String)
        Dim xmlSecurityDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim sSystem As String = ""
        Dim sClass As String = ""
        Dim sDesc As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSecurityDoc.LoadXml(sSecurity) 'node exists, fill local DOM
        sSystem = ""
        sClass = ""
        sDesc = ""

        'retrieve Security Classification System
        xmlNList = xmlSecurityDoc.SelectNodes("/secinfo/secsys")
        If (xmlNList.Count > 0) Then
            sSystem = xmlNList(0).InnerText.Trim
            f15.txtDataSecSys.Text = sSystem
        End If

        'retrieve Security Classification
        xmlNList = xmlSecurityDoc.SelectNodes("/secinfo/secclass")
        If (xmlNList.Count > 0) Then
            sClass = xmlNList(0).InnerText.Trim
            If (sClass = "") Then
                f15.cboxDataSecClass.SelectedIndex = -1
            Else
                'set the selection
                iSelInd = f15.cboxDataSecClass.FindStringExact(sClass)
                If (iSelInd = -1) Then
                    'add classification to combo box
                    f15.cboxDataSecClass.Items.Add(sClass)
                    f15.cboxDataSecClass.SelectedIndex = f15.cboxDataSecClass.Items.Count - 1
                Else
                    f15.cboxDataSecClass.SelectedIndex = iSelInd
                End If
            End If
        End If

        'retrieve Security Handling Description
        xmlNList = xmlSecurityDoc.SelectNodes("/secinfo/sechandl")
        If (xmlNList.Count > 0) Then
            sDesc = xmlNList(0).InnerText.Trim
            f15.txtDataSecDesc.Text = sDesc
        End If
        Return
    End Sub

    Private Sub openIDxref(ByVal sXRef As String)
        Dim xmlXRefDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sIDinfo As String = ""
        Dim sList As String
        Dim xmlCiteDoc As New XmlDocument
        Dim bCheck As Boolean = False
        Dim oCite As New CiteInfo
        Dim bLWC As Boolean = False
        Dim oCiteLWC As New CiteInfo

        xmlXRefDoc.LoadXml(sXRef) 'node exists, fill local DOM
        oCite = New CiteInfo
        bLWC = False
        oCiteLWC = New CiteInfo

        'retrieve Citation Information
        xmlNList = xmlXRefDoc.SelectNodes("/crossref/citeinfo")
        If (xmlNList.Count > 0) Then
            'process Citation
            sIDinfo = xmlNList(0).OuterXml
            xmlCiteDoc.LoadXml(sIDinfo)
            openCite(xmlCiteDoc, oCite, bCheck) 'main citation
            If (bCheck = False) Then
                'no required citation elements found
            Else
                sList = Microsoft.VisualBasic.Left(oCite.Author, 25) & "   " & Microsoft.VisualBasic.Left(oCite.Title, 25)
                f17.lboxXRef.Items.Add(sList) 'put citation ID into list box
                'look for Larger Work Citation
                xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                bCheck = False
                If (xmlPlist.Count > 0) Then
                    sIDinfo = xmlPlist(0).OuterXml
                    xmlCiteDoc.LoadXml(sIDinfo)
                    openCite(xmlCiteDoc, oCiteLWC, bCheck) 'larger work citation
                End If
                If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed

                'update the main collections
                f17.XRefBase.Add(oCite) 'add new citation to the collection
                f17.bXRefLWC.Add(bLWC) 'add new larger work Boolean to its collection
                f17.XRefLarge.Add(oCiteLWC) 'add new larger work citation to its collection
            End If
        End If
    End Sub

    Private Sub openIDtool(ByVal sTool As String)
        Dim xmlToolDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sIDinfo As String = ""
        Dim sList As String
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim oCurTool As New ToolClass
        Dim xmlCiteDoc As New XmlDocument
        Dim bCheck As Boolean = False
        Dim oCite As New CiteInfo
        Dim bLWC As Boolean = False
        Dim oCiteLWC As New CiteInfo
        Dim oNewContact As New ContactInfo

        xmlToolDoc.LoadXml(sTool) 'node exists, fill local DOM
        oCurTool = New ToolClass

        'retrieve Tool Description
        xmlNList = xmlToolDoc.SelectNodes("/tool/tooldesc")
        If (xmlNList.Count > 0) Then
            oCurTool.ToolDesc = xmlNList(0).InnerText.Trim
            f16.lboxTool.Items.Add(oCurTool.ToolDesc) 'add to list box display
        End If

        'retrieve Tool Access Information
        '  1. retrieve Online Linkage(s)
        xmlNList = xmlToolDoc.SelectNodes("/tool/toolacc/onlink")
        iCount = xmlNList.Count - 1
        sList = ""
        For iLoop = 0 To iCount
            sList += xmlNList(iLoop).InnerText.Trim & sKdelim
        Next
        oCurTool.ToolLink = sList

        '  2. retrieve Access Instructions
        xmlNList = xmlToolDoc.SelectNodes("/tool/toolacc/toolinst")
        If (xmlNList.Count > 0) Then
            oCurTool.ToolAccess = xmlNList(0).InnerText.Trim
        End If

        '  3. retrieve Computer and Operating System
        xmlNList = xmlToolDoc.SelectNodes("/tool/toolacc/toolcomp")
        If (xmlNList.Count > 0) Then
            oCurTool.ToolOS = xmlNList(0).InnerText.Trim
        End If

        'retrieve Tool Contact
        oNewContact = New ContactInfo
        xmlNList = xmlToolDoc.SelectNodes("/tool/toolcont/cntinfo")
        If (xmlNList.Count > 0) Then
            'get the Contact Information XML
            sIDinfo = xmlNList(0).OuterXml
            openContact(sIDinfo, oNewContact)
            oCurTool.boolContact = True
            oCurTool.ToolContact = oNewContact
        End If

        'retrieve Tool Citation Information
        xmlNList = xmlToolDoc.SelectNodes("/tool/toolcite/citeinfo")
        If (xmlNList.Count > 0) Then
            'process Citation
            oCite = New CiteInfo
            bLWC = False
            oCiteLWC = New CiteInfo
            sIDinfo = xmlNList(0).OuterXml
            xmlCiteDoc.LoadXml(sIDinfo)
            openCite(xmlCiteDoc, oCite, bCheck) 'main citation
            If (bCheck = False) Then
                'no required citation elements found
            Else
                'look for Larger Work Citation
                xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                bCheck = False
                If (xmlPlist.Count > 0) Then
                    sIDinfo = xmlPlist(0).OuterXml
                    xmlCiteDoc.LoadXml(sIDinfo)
                    openCite(xmlCiteDoc, oCiteLWC, bCheck) 'larger work citation
                End If
                If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed

                'update the tool object
                oCurTool.boolCitation = True
                oCurTool.ToolCite = oCite 'add citation to the tool object
                oCurTool.boolCiteLWC = bLWC 'add larger work Boolean to the object
                oCurTool.ToolCiteLWC = oCiteLWC 'add larger work citation to the object
            End If
        End If

        'add tool object to main collection and return
        f16.idTools.Add(oCurTool)
        Return
    End Sub

#End Region

#Region " DOM processing for Data Quality Information section "

    Private Sub openDQ(ByVal xmlOpenDQ As XmlDocument)
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim xmlRlist As XmlNodeList
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim sError As String = ""
        Dim sDQinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim bCloud As Boolean = False

        'retrieve Attribute Accuracy
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/attracc")
        If (xmlNList.Count > 0) Then
            '  1. retrieve Attribute Accuracy Report
            xmlPlist = xmlNList(0).SelectNodes("attraccr")
            If (xmlPlist.Count > 0) Then
                f21.txtAttribAcc.Text = xmlPlist(0).InnerText.Trim
            End If
            '  2. retrieve Attribute Accuracy Assessment(s)
            xmlPlist = xmlNList(0).SelectNodes("qattracc")
            iCount = xmlPlist.Count
            For iLoop = 0 To iCount - 1
                s1 = ""
                s2 = ""
                ' 2a. retrieve Attribute Accuracy Value
                xmlRlist = xmlPlist(iLoop).SelectNodes("attraccv")
                If (xmlRlist.Count > 0) Then
                    s1 = xmlRlist(0).InnerText.Trim
                End If
                ' 2b. retrieve Attribute Accuracy Explanation
                xmlRlist = xmlPlist(iLoop).SelectNodes("attracce")
                If (xmlRlist.Count > 0) Then
                    s2 = xmlRlist(0).InnerText.Trim
                End If
                If (s1 <> "" Or s2 <> "") Then
                    sList = s1 & ":  " & s2
                    f21.lboxAttribAcc.Items.Add(sList) 'update list box display
                    sList = s1 & sPdelim & s2
                    f21.sAttribAcc.Add(sList) 'update the main collection
                End If
            Next
        End If

        'retrieve Logical Consistency Report
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/logic")
        If (xmlNList.Count > 0) Then
            f22.txtLogic.Text = xmlNList(0).InnerText.Trim
        End If

        'retrieve Completeness Report
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/complete")
        If (xmlNList.Count > 0) Then
            f22.txtComplete.Text = xmlNList(0).InnerText.Trim
        End If

        'retrieve Positional Accuracy
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/posacc")
        If (xmlNList.Count > 0) Then
            sDQinfo = xmlNList(0).OuterXml
            openDQpos(sDQinfo)
        End If

        'retrieve Lineage
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/lineage")
        If (xmlNList.Count > 0) Then
            sDQinfo = xmlNList(0).OuterXml
            openDQlineage(sDQinfo)
        End If

        'retrieve Cloud Cover
        f25.rdoNoCloud.Checked = True
        xmlNList = xmlOpenDQ.SelectNodes("/dataqual/cloud")
        If (xmlNList.Count > 0) Then
            s1 = xmlNList(0).InnerText.Trim
            If (s1 = "Unknown") Then
                f25.rdoCloudUnk.Checked = True
            Else
                Try
                    bCloud = True
                    iCount = Convert.ToInt32(s1)
                Catch ex As Exception
                    bCloud = False
                    sError = "Cloud cover not an integer." & CrLf & "Set to 'Not reported'"
                    MessageBox.Show(sError, "Cloud cover error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
                If (bCloud = True) Then
                    If (iCount > -1 And iCount < 101) Then
                        f25.rdoCloud.Checked = True
                        f25.numCloud.Value = Convert.ToDecimal(iCount)
                    Else
                        sError = "Cloud cover, " & iCount.ToString & ", outside of range." & CrLf & "Set to 'Not reported'"
                        MessageBox.Show(sError, "Cloud cover error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                End If
            End If
        End If

    End Sub

    Private Sub openDQpos(ByVal sPosAcc As String)
        Dim xmlDataQDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim xmlRlist As XmlNodeList
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim sError As String = ""
        Dim sDQinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim bReal As Boolean = False
        Dim rAccVal As Double = 0.0

        xmlDataQDoc.LoadXml(sPosAcc)

        'retrieve Horizontal Positional Accuracy
        xmlNList = xmlDataQDoc.SelectNodes("/posacc/horizpa")
        If (xmlNList.Count > 0) Then
            '  1. retrieve horizontal positional accuracy report
            xmlPlist = xmlNList(0).SelectNodes("horizpar")
            If (xmlPlist.Count > 0) Then
                f23.txtHorAccRpt.Text = xmlPlist(0).InnerText.Trim
            End If
            '  2. retrieve quantitative horizontal positional accuracy assessment
            xmlPlist = xmlNList(0).SelectNodes("qhorizpa")
            iCount = xmlPlist.Count
            For iLoop = 0 To iCount - 1
                s1 = ""
                s2 = ""
                ' 2a. retrieve the accuracy explanation (simple string)
                xmlRlist = xmlPlist(iLoop).SelectNodes("horizpae")
                If (xmlRlist.Count > 0) Then
                    s2 = xmlRlist(0).InnerText.Trim
                End If
                ' 2b. retrieve the accuracy value and test for conformance (real value >= 0)
                xmlRlist = xmlPlist(iLoop).SelectNodes("horizpav")
                If (xmlRlist.Count > 0) Then
                    s1 = xmlRlist(0).InnerText.Trim
                    Try
                        bReal = True
                        rAccVal = Convert.ToDouble(s1)
                    Catch ex As Exception
                        bReal = False
                        sError = "Horizontal Accuracy Value, " & s1 & ", is not a real number"
                        sError += CrLf & "Reset to 0.00"
                        MessageBox.Show(sError, "Accuracy Value error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                    If (bReal = True) Then
                        If (rAccVal >= 0.0) Then
                            'do nothing
                        Else
                            s1 = "0.00"
                            sError = "Horizontal Positional Accuracy Value < 0.00" & CrLf & "Set to 0.00"
                            MessageBox.Show(sError, "Quantitative Accuracy Assessment error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        End If
                    Else
                        s1 = "0.00"
                    End If
                End If
                sList = s1 & " m:  " & s2
                f23.lboxHPosAcc.Items.Add(sList) 'update the list box display
                sList = s1 & sPdelim & s2
                f23.sHPosAcc.Add(sList) 'update main collection
            Next
        End If

        'retrieve Vertical Positional Accuracy
        xmlNList = xmlDataQDoc.SelectNodes("/posacc/vertacc")
        If (xmlNList.Count > 0) Then
            '  1. retrieve vertical positional accuracy report
            xmlPlist = xmlNList(0).SelectNodes("vertaccrr")
            If (xmlPlist.Count > 0) Then
                f23.txtVertAccRpt.Text = xmlPlist(0).InnerText.Trim
            End If
            '  2. retrieve quantitative vertical positional accuracy assessment
            xmlPlist = xmlNList(0).SelectNodes("qvertpa")
            iCount = xmlPlist.Count
            For iLoop = 0 To iCount - 1
                s1 = ""
                s2 = ""
                ' 2a. retrieve the accuracy explanation (simple string)
                xmlRlist = xmlPlist(iLoop).SelectNodes("vertacce")
                If (xmlRlist.Count > 0) Then
                    s2 = xmlRlist(0).InnerText.Trim
                End If
                ' 2b. retrieve the accuracy value and test for conformance (real value >= 0)
                xmlRlist = xmlPlist(iLoop).SelectNodes("vertaccv")
                If (xmlRlist.Count > 0) Then
                    s1 = xmlRlist(0).InnerText.Trim
                    Try
                        bReal = True
                        rAccVal = Convert.ToDouble(s1)
                    Catch ex As Exception
                        bReal = False
                        sError = "Vertical Accuracy Value, " & s1 & ", is not a real number"
                        sError += CrLf & "Reset to 0.00"
                        MessageBox.Show(sError, "Accuracy Value error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                    If (bReal = True) Then
                        If (rAccVal >= 0.0) Then
                            'do nothing
                        Else
                            s1 = "0.00"
                            sError = "Vertical Positional Accuracy Value < 0.00" & CrLf & "Set to 0.00"
                            MessageBox.Show(sError, "Quantitative Accuracy Assessment error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        End If
                    Else
                        s1 = "0.00"
                    End If
                End If
                sList = s1 & " m:  " & s2
                f23.lboxVPosAcc.Items.Add(sList) 'update the list box display
                sList = s1 & sPdelim & s2
                f23.sVPosAcc.Add(sList) 'update main collection
            Next
        End If
    End Sub

    Private Sub openDQlineage(ByVal sLineage As String)
        Dim xmlDataQDoc As New XmlDocument
        Dim xmlNList As XmlNodeList
        Dim sDQinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlDataQDoc.LoadXml(sLineage) 'node exists, fill local DOM

        'retrieve Methodology
        xmlNList = xmlDataQDoc.SelectNodes("/lineage/method")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sDQinfo = xmlNList(iLoop).OuterXml
            openDQmethod(sDQinfo)
        Next

        'retrieve Source Information
        xmlNList = xmlDataQDoc.SelectNodes("/lineage/srcinfo")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sDQinfo = xmlNList(iLoop).OuterXml
            openDQsource(sDQinfo)
        Next

        'retrieve Process Step
        xmlNList = xmlDataQDoc.SelectNodes("/lineage/procstep")
        iCount = xmlNList.Count
        For iLoop = 0 To iCount - 1
            sDQinfo = xmlNList(iLoop).OuterXml
            openDQprocess(sDQinfo)
        Next
    End Sub

    Private Sub openDQmethod(ByVal sMethod As String)
        Dim xmlDataQDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sThesaurus As String = ""
        Dim sKey As String = ""
        Dim s1 As String = ""
        Dim sDQinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sList As String
        Dim oNewMethod As New MethodClass
        Dim sMethIDs As New StringCollection
        Dim xmlCiteDoc As New XmlDocument
        Dim bCheck As Boolean = False
        Dim oCite As New CiteInfo
        Dim bLWC As Boolean = False
        Dim oCiteLWC As New CiteInfo

        xmlDataQDoc.LoadXml(sMethod) 'node exists, fill local DOM
        oNewMethod = New MethodClass

        'retrieve Methodology Type
        xmlNlist = xmlDataQDoc.SelectNodes("/method/methtype")
        If (xmlNlist.Count > 0) Then
            oNewMethod.MethodType = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Methodology Identifier(s)
        xmlNlist = xmlDataQDoc.SelectNodes("/method/methodid")
        iCount = xmlNlist.Count
        For iLoop = 0 To iCount - 1
            ' 1. retrieve methodology keyword thesaurus
            sThesaurus = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("methkt")
            If (xmlPlist.Count > 0) Then
                sThesaurus = xmlPlist(0).InnerText.Trim
            End If
            ' 2. retrieve methodology keywords
            sKey = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("methkey")
            kCount = xmlPlist.Count
            For kLoop = 0 To kCount - 1
                s1 = xmlPlist(kLoop).InnerText.Trim
                If (s1 <> "") Then
                    sKey += s1 & sKdelim
                End If
            Next
            If (sKey <> "" And sThesaurus = "") Then sThesaurus = "None"
            If (sKey = "" And sThesaurus = "") Then
                'do nothing, incomplete information considered error condition
            Else
                sThesaurus += sPdelim & sKey
                sMethIDs.Add(sThesaurus) 'add methodology identifier to collection
            End If
        Next
        oNewMethod.MethodID = sMethIDs 'place identifier collection into object

        'retrieve Methodology Description
        xmlNlist = xmlDataQDoc.SelectNodes("/method/methdesc")
        If (xmlNlist.Count > 0) Then
            oNewMethod.MethodDesc = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Methodology Citations
        xmlNlist = xmlDataQDoc.SelectNodes("/method/methcite")
        iCount = xmlNlist.Count
        For iLoop = 0 To iCount - 1
            oCite = New CiteInfo
            bLWC = False
            oCiteLWC = New CiteInfo

            'retrieve Citation
            xmlPlist = xmlNlist(iLoop).SelectNodes("citeinfo")
            kCount = xmlPlist.Count
            If (kCount > 0) Then
                'process Citation
                sDQinfo = xmlPlist(0).OuterXml
                xmlCiteDoc.LoadXml(sDQinfo)
                openCite(xmlCiteDoc, oCite, bCheck) 'main citation
                If (bCheck = False) Then
                    'no required citation elements found
                Else
                    'look for Larger Work Citation
                    xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                    bCheck = False
                    If (xmlPlist.Count > 0) Then
                        sDQinfo = xmlPlist(0).OuterXml
                        xmlCiteDoc.LoadXml(sDQinfo)
                        openCite(xmlCiteDoc, oCiteLWC, bCheck) 'larger work citation
                    End If
                    If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed
                    'update the object
                    oNewMethod.CiteAdd()
                    iSelInd = oNewMethod.CiteCount '1-based collection
                    oNewMethod.CiteUpdate(oCite, iSelInd)
                    oNewMethod.LWCUpdate(bLWC, oCiteLWC, iSelInd)
                End If
            End If
        Next

        f24.cMethods.Add(oNewMethod) 'place completed object into main collection
        sList = oNewMethod.MethodType & ":  " & Microsoft.VisualBasic.Left(oNewMethod.MethodDesc, 60)
        f24.lboxMeth.Items.Add(sList) 'place identifier into list box display
        Return
    End Sub

    Private Sub openDQsource(ByVal sSource As String)
        Dim xmlDataQDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim oNewSource As New SourceClass
        Dim sThesaurus As String = ""
        Dim sKey As String = ""
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sDQinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim xmlCiteDoc As New XmlDocument
        Dim bCheck As Boolean = False
        Dim oCite As New CiteInfo
        Dim bLWC As Boolean = False
        Dim oCiteLWC As New CiteInfo
        Dim oTSource As New SourceClass
        Dim oTColl As New Collection
        Dim oTimeDoc As New XmlDocument

        xmlDataQDoc.LoadXml(sSource) 'node exists, fill local DOM
        oNewSource = New SourceClass

        'retrieve Source Citation
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/srccite/citeinfo")
        If (xmlNlist.Count > 0) Then
            oCite = New CiteInfo
            bLWC = False
            oCiteLWC = New CiteInfo

            'process Citation
            sDQinfo = xmlNlist(0).OuterXml
            xmlCiteDoc.LoadXml(sDQinfo)
            openCite(xmlCiteDoc, oCite, bCheck) 'main citation
            If (bCheck = False) Then
                'no required citation elements found
            Else
                'look for Larger Work Citation
                xmlPlist = xmlCiteDoc.SelectNodes("/citeinfo/lworkcit/citeinfo")
                bCheck = False
                If (xmlPlist.Count > 0) Then
                    sDQinfo = xmlPlist(0).OuterXml
                    xmlCiteDoc.LoadXml(sDQinfo)
                    openCite(xmlCiteDoc, oCiteLWC, bCheck) 'larger work citation
                End If
                If (bCheck = True) Then bLWC = True 'a Larger Work Citation was processed

                'update the source object
                oNewSource.SourceCite = oCite
                oNewSource.boolLWC = bLWC
                oNewSource.SourceLWC = oCiteLWC
            End If
        End If

        'retrieve Source Scale Denominator
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/srcscale")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            Try
                iCount = Convert.ToInt32(s1)
            Catch ex As Exception
                sError = "Source Scale Denominator, " & s1 & ", cannot be converted to an integer."
                sError += CrLf & "Denominator not set"
                MessageBox.Show(sError, "Source Scale Denominator error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                s1 = ""
                iCount = 5 'value not actually used
            End Try
            If (iCount < 2) Then
                sError = "Source Scale Denominator, " & s1 & ", is not > 1."
                sError += CrLf & "Denominator not set"
                MessageBox.Show(sError, "Source Scale Denominator error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                s1 = ""
            End If
            oNewSource.ScaleDenom = s1 'either blank or valid integer as string
        End If

        'retrieve Type of Source Media
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/typesrc")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            oNewSource.Media = s1
        End If

        'retrieve Time Period of Content
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/srctime")
        If (xmlNlist.Count > 0) Then
            '  1. retrieve Time Period Information
            xmlPlist = xmlNlist(0).SelectNodes("timeinfo")
            If (xmlPlist.Count > 0) Then
                sDQinfo = xmlPlist(0).OuterXml
                oTimeDoc.LoadXml(sDQinfo)
                openTimeInfo(oTimeDoc, oTSource, oTColl)
                oNewSource.boolRange = oTSource.boolRange
                oNewSource.boolSingle = oTSource.boolSingle
                oNewSource.Gregorian = oTSource.Gregorian
                oNewSource.TimePeriod = oTColl
            End If
            '  2. retrieve Source Currentness Reference
            xmlPlist = xmlNlist(0).SelectNodes("srccurr")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                oNewSource.Currentness = s1
            End If
        End If

        'retrieve Source Citation Abbreviation
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/srccitea")
        If (xmlNlist.Count > 0) Then
            oNewSource.CiteAbbrv = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Source Contribution
        xmlNlist = xmlDataQDoc.SelectNodes("/srcinfo/srccontr")
        If (xmlNlist.Count > 0) Then
            oNewSource.Contrib = xmlNlist(0).InnerText.Trim
        End If

        'update main collection and list box display
        f24.cSources.Add(oNewSource)
        s1 = oNewSource.CiteAbbrv & ":  " & Microsoft.VisualBasic.Left(oNewSource.Contrib, 40)
        f24.lboxLinSource.Items.Add(s1)
        Return
    End Sub

    Private Sub openDQprocess(ByVal sProcess As String)
        Dim xmlDataQDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim oNewProc As New ProcessClass
        Dim sThesaurus As String = ""
        Dim sKey As String = ""
        Dim s1 As String = ""
        Dim sTitle As String = ""
        Dim sError As String = ""
        Dim sDQinfo As String = ""
        Dim iSelInd As Integer = 0
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sKeyArray() As String
        Dim sList As String
        Dim xmlCiteDoc As New XmlDocument
        Dim oContact As New ContactInfo
        Dim bDate As Boolean = False

        xmlDataQDoc.LoadXml(sProcess) 'node exists, fill local DOM
        oNewProc = New ProcessClass
        oContact = New ContactInfo

        'retrieve Process Description
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/procdesc")
        If (xmlNlist.Count > 0) Then
            oNewProc.Description = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Source Used Abbreviation(s)
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/srcused")
        iCount = xmlNlist.Count
        sKey = ""
        For iLoop = 0 To iCount - 1
            s1 = xmlNlist(iLoop).InnerText.Trim
            If (s1 <> "") Then
                sKey += s1 & sKdelim
            End If
        Next
        oNewProc.UsedAbbrv = sKey

        'retrieve Process Date
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/procdate")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            Select Case s1
                Case "Unknown", "Not complete"
                    'valid entries
                Case Else
                    evalDate(s1, bDate)
                    If (bDate = True) Then
                        'have valid date
                    Else
                        sTitle = "Data Quality Info — Lineage error"
                        sError = "Process Date  " & s1 & "  is not in correct date format."
                        sError += "Date set to Unknown."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        s1 = "Unknown"
                    End If
            End Select
            oNewProc.ProcessDate = s1
        End If

        'retrieve Process Time
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/proctime")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            chkTime(s1)
            oNewProc.ProcessTime = s1
        End If

        'retrieve Source Produced Abbreviation(s)
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/srcprod")
        iCount = xmlNlist.Count
        sKey = ""
        For iLoop = 0 To iCount - 1
            s1 = xmlNlist(iLoop).InnerText.Trim
            If (s1 <> "") Then
                sKey += s1 & sKdelim
            End If
        Next
        oNewProc.ProducedAbbrv = sKey

        'retrieve Process Contact
        xmlNlist = xmlDataQDoc.SelectNodes("/procstep/proccont/cntinfo")
        If (xmlNlist.Count > 0) Then
            'get the Contact Information XML
            sDQinfo = xmlNlist(0).OuterXml
            openContact(sDQinfo, oContact)
            oNewProc.ProcessContact = oContact
        End If

        'add object to main collection and place entry in list box display
        f24.cProcess.Add(oNewProc)
        s1 = Microsoft.VisualBasic.Left(oNewProc.Description, 60)
        f24.lboxProcess.Items.Add(s1)
        Return
    End Sub

#End Region

#Region " DOM processing for Spatial Data Organization Information section "

    Private Sub openSpDO(ByVal xmlOpenSpDO As XmlDocument)
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim sSpDOinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0

        'retrieve Indirect Spatial Reference
        xmlNlist = xmlOpenSpDO.SelectNodes("/spdoinfo/indspref")
        If (xmlNlist.Count > 0) Then
            f31.txtIndirect.Text = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Direct Spatial Reference Method
        xmlNlist = xmlOpenSpDO.SelectNodes("/spdoinfo/direct")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            iCount = f31.cboxDirect.FindStringExact(s1)
            f31.cboxDirect.SelectedIndex = iCount
        End If

        'retrieve appropriate Object Information, if available
        Select Case s1
            Case "Point", "Vector"
                'retrieve point and vector object information
                xmlNlist = xmlOpenSpDO.SelectNodes("/spdoinfo/ptvctinf/sdtsterm")
                iCount = xmlNlist.Count
                If (iCount > 0) Then
                    'process SDTS terms
                    f32.rdoSDTS.Checked = True
                    For iLoop = 0 To iCount - 1
                        sSpDOinfo = xmlNlist(iLoop).OuterXml
                        openSPDOvector(sSpDOinfo, "sdts")
                    Next
                Else
                    'look for VPF terms
                    xmlNlist = xmlOpenSpDO.SelectNodes("/spdoinfo/ptvctinf/vpfterm")
                    If (xmlNlist.Count > 0) Then
                        'process VPF Terms Description
                        f32.rdoVPF.Checked = True
                        ' 1. retrieve VPF topology level
                        xmlPlist = xmlNlist(0).SelectNodes("vpflevel")
                        If (xmlPlist.Count > 0) Then
                            s1 = xmlPlist(0).InnerText.Trim
                            kCount = f32.cboxVPF.FindStringExact(s1)
                            f32.cboxVPF.SelectedIndex = kCount
                            If (kCount = -1) Then
                                'provide error msg, incorrect VPF topology level
                                sError = "VPF Topology Level, " & s1 & ", is not valid." & sKdelim
                                sError += "It will be ignored."
                                sTitle = "Spatial Data Organization error"
                                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                            End If
                        End If
                        ' 2. retrieve VPF object information
                        xmlPlist = xmlNlist(0).SelectNodes("vpfinfo")
                        kCount = xmlPlist.Count - 1
                        For iLoop = 0 To kCount
                            sSpDOinfo = xmlPlist(iLoop).OuterXml
                            openSPDOvector(sSpDOinfo, "vpf")
                        Next
                    End If
                End If
            Case "Raster"
                'retrieve raster object information
                xmlNlist = xmlOpenSpDO.SelectNodes("/spdoinfo/rastinfo")
                If (xmlNlist.Count > 0) Then
                    sSpDOinfo = xmlNlist(0).OuterXml
                    openSPDOraster(sSpDOinfo)
                End If
            Case ""
                'do nothing, blank value
            Case Else
                'provide error msg, incorrect Direct Spatial Reference Method
                sError = "Direct Spatial Reference Method, " & s1 & ", is not a valid method!" & sKdelim
                sError += "Reference Method and Object Information ignored."
                sTitle = "Spatial Data Organization error"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Select
    End Sub

    Private Sub openSPDOvector(ByVal sTerms As String, ByVal sType As String)
        'sType is either "sdts" or "vpf"
        Dim xmlSpDODoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim sList As String
        Dim bInteger As Boolean = False

        xmlSpDODoc.LoadXml(sTerms)

        'retrieve Object Type
        s1 = ""
        If (sType = "sdts") Then
            xmlNlist = xmlSpDODoc.SelectNodes("/sdtsterm/sdtstype")
            If (xmlNlist.Count > 0) Then
                s1 = xmlNlist(0).InnerText.Trim
            End If
        Else
            xmlNlist = xmlSpDODoc.SelectNodes("/vpfinfo/vpftype")
            If (xmlNlist.Count > 0) Then
                s1 = xmlNlist(0).InnerText.Trim
            End If
        End If

        'retrieve Object Count
        s2 = "0"
        If (sType = "sdts") Then
            xmlNlist = xmlSpDODoc.SelectNodes("/sdtsterm/ptvctcnt")
            If (xmlNlist.Count > 0) Then
                s2 = xmlNlist(0).InnerText.Trim
            End If
        Else
            xmlNlist = xmlSpDODoc.SelectNodes("/vpfinfo/ptvctcnt")
            If (xmlNlist.Count > 0) Then
                s2 = xmlNlist(0).InnerText.Trim
            End If
        End If
        chkInteger(s2, iCount, bInteger)
        If (bInteger = False) Then
            s2 = "0"
        Else
            Select Case iCount
                Case Is < 0
                    sError = "Vector Object Information" & CrLf
                    sError += "Object Count, " & s1 & ", less than 0. Value reset to 0."
                    sTitle = "Spatial Data Organization error"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    iCount = 0
                Case Is > 1000000 'one million is current upper bound set for numeric control
                    sError = "Vector Object Information" & CrLf
                    sError += "Object Count, " & s1 & ", > 1 million. Value reset to 1 million."
                    sTitle = "Spatial Data Organization error"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    iCount = 1000000
            End Select
            s2 = iCount.ToString
        End If

        'update main string collection and list box display
        If (s1 <> "") Then
            sList = s1 & sPdelim & s2
            f32.sSDTS.Add(sList)
            sList = Replace(sList, sPdelim, "  :  ")
            f32.lboxTerms.Items.Add(sList)
        End If
        Return
    End Sub

    Private Sub openSPDOraster(ByVal sRaster As String)
        Dim xmlSpDODoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim bInteger As Boolean = False

        xmlSpDODoc.LoadXml(sRaster)

        'retrieve Raster Object Type
        xmlNlist = xmlSpDODoc.SelectNodes("/rastinfo/rasttype")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            iCount = f33.cboxRasType.FindStringExact(s1)
            f33.cboxRasType.SelectedIndex = iCount
        End If

        'retrieve Row Count
        xmlNlist = xmlSpDODoc.SelectNodes("/rastinfo/rowcount")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            chkInteger(s1, iCount, bInteger)
            If (bInteger = True) Then
                Select Case iCount
                    Case Is < 0
                        sError = "Raster Object Information" & CrLf
                        sError += "Row Count, " & s1 & ", less than 0. Value reset to 0."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 0
                    Case Is > 1000000000 'one billion is current upper bound set for numeric control
                        sError = "Raster Object Information" & CrLf
                        sError += "Row Count, " & s1 & ", > 1 million. Value reset to 1 billion."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 1000000000
                End Select
                f33.numRasRow.Value = Convert.ToDecimal(iCount) 'place checked integer into numeric control
            Else
                sError = "Raster Object Information" & CrLf
                sError += "Row Count, " & s1 & ", could not be converted to an integer."
                MessageBox.Show(sError, "Spatial Data Organization error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        'retrieve Column Count
        xmlNlist = xmlSpDODoc.SelectNodes("/rastinfo/colcount")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            chkInteger(s1, iCount, bInteger)
            If (bInteger = True) Then
                Select Case iCount
                    Case Is < 0
                        sError = "Raster Object Information" & CrLf
                        sError += "Column Count, " & s1 & ", less than 0. Value reset to 0."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 0
                    Case Is > 1000000000 'one billion is current upper bound set for numeric control
                        sError = "Raster Object Information" & CrLf
                        sError += "Column Count, " & s1 & ", > 1 million. Value reset to 1 billion."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 1000000000
                End Select
                f33.numRasCol.Value = Convert.ToDecimal(iCount) 'place checked integer into numeric control
            Else
                sError = "Raster Object Information" & CrLf
                sError += "Column Count, " & s1 & ", could not be converted to an integer."
                MessageBox.Show(sError, "Spatial Data Organization error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        'retrieve Vertical Count
        xmlNlist = xmlSpDODoc.SelectNodes("/rastinfo/vrtcount")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            chkInteger(s1, iCount, bInteger)
            If (bInteger = True) Then
                Select Case iCount
                    Case Is < 0
                        sError = "Raster Object Information" & CrLf
                        sError += "Vertical Count, " & s1 & ", less than 0. Value reset to 0."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 0
                    Case Is > 1000000000 'one billion is current upper bound set for numeric control
                        sError = "Raster Object Information" & CrLf
                        sError += "Vertical Count, " & s1 & ", > 1 million. Value reset to 1 billion."
                        sTitle = "Spatial Data Organization error"
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        iCount = 1000000000
                End Select
                f33.numRasVert.Value = Convert.ToDecimal(iCount) 'place checked integer into numeric control
            Else
                sError = "Raster Object Information" & CrLf
                sError += "Vertical Count, " & s1 & ", could not be converted to an integer."
                MessageBox.Show(sError, "Spatial Data Organization error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If
        Return
    End Sub

    Private Sub chkInteger(ByVal s1 As String, ByRef iValue As Integer, ByRef bTrans As Boolean)
        Try
            bTrans = True
            iValue = Convert.ToInt32(s1)
        Catch ex As Exception
            bTrans = False
            iValue = 0
        End Try
    End Sub

#End Region

#Region " DOM processing for Spatial Reference Information section "

    Private Sub openSpRef(ByVal xmlOpenSpRef As XmlDocument)
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sSpRefinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim jCount As Integer = 0

        'retrieve Horizontal Coordinate System Definition
        xmlNlist = xmlOpenSpRef.SelectNodes("/spref/horizsys")
        If (xmlNlist.Count > 0) Then
            ' 1. retrieve Geographic definition
            xmlPlist = xmlNlist(0).SelectNodes("geograph")
            kCount = xmlPlist.Count
            If (kCount > 0) Then
                f41.rdoGeographic.Checked = True
                sSpRefinfo = xmlPlist(0).OuterXml
                openSRgeog(sSpRefinfo)
            Else
                ' 2. OR retrieve Local definition
                xmlPlist = xmlNlist(0).SelectNodes("local")
                jCount = xmlPlist.Count
                If (jCount > 0) Then
                    f41.rdoLocal.Checked = True
                    sSpRefinfo = xmlPlist(0).OuterXml
                    openSRlocal(sSpRefinfo)
                Else
                    ' 3. OR retrieve Planar definition(s)
                    xmlPlist = xmlNlist(0).SelectNodes("planar")
                    iCount = xmlPlist.Count - 1
                    If (xmlPlist.Count > 0) Then f41.rdoPlanar.Checked = True
                    For iLoop = 0 To iCount
                        sSpRefinfo = xmlPlist(iLoop).OuterXml
                        openSRplanar(sSpRefinfo)
                    Next
                End If
            End If
            ' 4. retrieve Geodetic Model
            xmlPlist = xmlNlist(0).SelectNodes("geodetic")
            If (xmlPlist.Count > 0) Then
                sSpRefinfo = xmlPlist(0).OuterXml
                openSRgeodetic(sSpRefinfo)
            End If
        End If

        'retrieve Vertical Coordinate System Definition
        xmlNlist = xmlOpenSpRef.SelectNodes("/spref/vertdef")
        If (xmlNlist.Count > 0) Then
            ' 1. retrieve Altitude System Definition
            xmlPlist = xmlNlist(0).SelectNodes("altsys")
            If (xmlPlist.Count > 0) Then
                sSpRefinfo = xmlPlist(0).OuterXml
                openSRaltitude(sSpRefinfo)
            End If
            ' 2. retrieve Depth System Definition
            xmlPlist = xmlNlist(0).SelectNodes("depthsys")
            If (xmlPlist.Count > 0) Then
                sSpRefinfo = xmlPlist(0).OuterXml
                openSRdepth(sSpRefinfo)
            End If
        End If
    End Sub

    Private Sub openSRgeog(ByVal sGeog As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sGeog)
        sTitle = "Spatial Reference error"

        'retrieve Latitude Resolution
        xmlNlist = xmlSpRefDoc.SelectNodes("/geograph/latres")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal > 90.0) Then rVal = 90.0 'truncate to maximum value of numeric control
                If (rVal >= 0.0) Then
                    f41.numLatRes.Value = Convert.ToDecimal(rVal) 'put resolution into control
                Else
                    sError = "Geographic Definition" & CrLf
                    sError += "Latitude Resolution, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Geographic Definition" & CrLf
                sError += "Latitude Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        'retrieve Longitude Resolution
        xmlNlist = xmlSpRefDoc.SelectNodes("/geograph/longres")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal > 180.0) Then rVal = 180.0 'truncate to maximum value of numeric control
                If (rVal >= 0.0) Then
                    f41.numLongRes.Value = Convert.ToDecimal(rVal) 'put resolution into control
                Else
                    sError = "Geographic Definition" & CrLf
                    sError += "Longitude Resolution, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Geographic Definition" & CrLf
                sError += "Longitude Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        'retrieve Geographic Coordinate Units
        xmlNlist = xmlSpRefDoc.SelectNodes("/geograph/geogunit")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            'select coordinate units for combo box display
            iCount = f41.cboxGeoCoorUnits.FindStringExact(s1)
            f41.cboxGeoCoorUnits.SelectedIndex = iCount
        End If
    End Sub

    Private Sub openSRlocal(ByVal sLocal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList

        xmlSpRefDoc.LoadXml(sLocal)

        'retrieve Local Description
        xmlNlist = xmlSpRefDoc.SelectNodes("/local/localdes")
        If (xmlNlist.Count > 0) Then
            f41.txtLocalDesc.Text = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Local Georeference Information
        xmlNlist = xmlSpRefDoc.SelectNodes("/local/localgeo")
        If (xmlNlist.Count > 0) Then
            f41.txtLocalGeoInfo.Text = xmlNlist(0).InnerText.Trim
        End If
    End Sub

    Private Sub openSRplanar(ByVal sPlanar As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sSpRefInfo As String = ""
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False
        Dim oPlanar As New PlanarClass

        xmlSpRefDoc.LoadXml(sPlanar)
        oPlanar = New PlanarClass

        'retrieve Planar Coordinate Information
        xmlNlist = xmlSpRefDoc.SelectNodes("/planar/planci")
        If (xmlNlist.Count > 0) Then
            sSpRefInfo = xmlNlist(0).OuterXml
            openSRplanarCoord(sSpRefInfo, oPlanar)
        End If

        'retrieve Map Projection
        xmlNlist = xmlSpRefDoc.SelectNodes("/planar/mapproj")
        If (xmlNlist.Count > 0) Then
            sSpRefInfo = xmlNlist(0).OuterXml
            openSRplanarMap(sSpRefInfo, oPlanar)
            openSRplanarUpdate(oPlanar)
            Return
        End If

        'OR retrieve Grid Coordinate System
        xmlNlist = xmlSpRefDoc.SelectNodes("/planar/gridsys")
        If (xmlNlist.Count > 0) Then
            sSpRefInfo = xmlNlist(0).OuterXml
            openSRplanarGrid(sSpRefInfo, oPlanar)
            openSRplanarUpdate(oPlanar)
            Return
        End If

        'OR retrieve Local Planar
        xmlNlist = xmlSpRefDoc.SelectNodes("/planar/localp")
        If (xmlNlist.Count > 0) Then
            oPlanar.LocalPlanar = True
            ' 1. retrieve Local Planar Description
            xmlPlist = xmlNlist(0).SelectNodes("localpd")
            If (xmlPlist.Count > 0) Then
                oPlanar.LocalDesc = xmlPlist(0).InnerText.Trim
            End If
            ' 2. retrieve Local Planar Georeference Information
            xmlPlist = xmlNlist(0).SelectNodes("localpgi")
            If (xmlPlist.Count > 0) Then
                oPlanar.LocalGeoRef = xmlPlist(0).InnerText.Trim
            End If
            openSRplanarUpdate(oPlanar)
            Return
        End If
    End Sub

    Private Sub openSRplanarCoord(ByVal sPlanar As String, ByRef oPlanar As PlanarClass)
        'retrieve Planar Coordinate Information
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sPlanar)
        sTitle = "Spatial Reference error"

        'retrieve Planar Coordinate Encoding Method
        xmlNlist = xmlSpRefDoc.SelectNodes("/planci/plance")
        If (xmlNlist.Count > 0) Then
            oPlanar.Encoding = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Planar Distance Units
        xmlNlist = xmlSpRefDoc.SelectNodes("/planci/plandu")
        If (xmlNlist.Count > 0) Then
            oPlanar.PlanarUnits = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Coordinate Representation
        xmlNlist = xmlSpRefDoc.SelectNodes("/planci/coordrep")
        iCount = xmlNlist.Count
        If (iCount > 0) Then
            oPlanar.CoorRep = True
            ' 1. retrieve Abcissa Resolution
            xmlPlist = xmlNlist(0).SelectNodes("absres")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                realCheck(s1, rVal, bReal)
                If (bReal = True) Then
                    If (rVal > 100000.0) Then
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Abscissa Resolution, " & s1 & ", > 100,000 -- max value for control."
                        sError += "Value reduced to 100,000."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        rVal = 100000.0
                    End If
                    If (rVal >= 0.0) Then
                        oPlanar.Abscissa = Convert.ToDecimal(rVal)
                    Else
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Abscissa Resolution, " & s1 & ", less than 0. Value ignored."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                Else
                    sError = "Planar Coordinate Representation" & CrLf
                    sError += "Abscissa Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                    sError += "Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
            ' 2. retrieve Ordinate Resolution
            xmlPlist = xmlNlist(0).SelectNodes("ordres")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                realCheck(s1, rVal, bReal)
                If (bReal = True) Then
                    If (rVal > 100000.0) Then
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Ordinate Resolution, " & s1 & ", > 100,000 -- max value for control."
                        sError += "Value reduced to 100,000."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        rVal = 100000.0
                    End If
                    If (rVal >= 0.0) Then
                        oPlanar.Ordinate = Convert.ToDecimal(rVal)
                    Else
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Ordinate Resolution, " & s1 & ", less than 0. Value ignored."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                Else
                    sError = "Planar Coordinate Representation" & CrLf
                    sError += "Ordinate Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                    sError += "Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
            Return 'if Coordinate Representation present, do not look for Distance & Bearing Representation
        End If

        ' OR retrieve Distance and Bearing Representation
        xmlNlist = xmlSpRefDoc.SelectNodes("/planci/distbrep")
        If (xmlNlist.Count > 0) Then
            oPlanar.BearingRep = True
            ' 1. retrieve Distance Resolution
            xmlPlist = xmlNlist(0).SelectNodes("distres")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                realCheck(s1, rVal, bReal)
                If (bReal = True) Then
                    If (rVal > 100000.0) Then
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Distance Resolution, " & s1 & ", > 100,000 -- max value for control."
                        sError += "Value reduced to 100,000."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        rVal = 100000.0
                    End If
                    If (rVal >= 0.0) Then
                        oPlanar.DistanceRes = Convert.ToDecimal(rVal)
                    Else
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Distance Resolution, " & s1 & ", less than 0. Value ignored."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                Else
                    sError = "Planar Coordinate Representation" & CrLf
                    sError += "Distance Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                    sError += "Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
            ' 2. retrieve Bearing Resolution
            xmlPlist = xmlNlist(0).SelectNodes("bearres")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                realCheck(s1, rVal, bReal)
                If (bReal = True) Then
                    If (rVal > 100000.0) Then
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Bearing Resolution, " & s1 & ", > 100,000 -- max value for control."
                        sError += "Value reduced to 100,000."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        rVal = 100000.0
                    End If
                    If (rVal >= 0.0) Then
                        oPlanar.BearingRes = Convert.ToDecimal(rVal)
                    Else
                        sError = "Planar Coordinate Representation" & CrLf
                        sError += "Bearing Resolution, " & s1 & ", less than 0. Value ignored."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End If
                Else
                    sError = "Planar Coordinate Representation" & CrLf
                    sError += "Bearing Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                    sError += "Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            End If
            ' 3. retrieve Bearing Units
            xmlPlist = xmlNlist(0).SelectNodes("bearunit")
            If (xmlPlist.Count > 0) Then
                oPlanar.BearingUnits = xmlPlist(0).InnerText.Trim
            End If
            ' 4. retrieve Bearing Reference Direction
            xmlPlist = xmlNlist(0).SelectNodes("bearrefd")
            If (xmlPlist.Count > 0) Then
                oPlanar.BearingDir = xmlPlist(0).InnerText.Trim
            End If
            ' 5. retrieve Bearing Reference Meridian
            xmlPlist = xmlNlist(0).SelectNodes("bearrefm")
            If (xmlPlist.Count > 0) Then
                oPlanar.BearingMerid = xmlPlist(0).InnerText.Trim
            End If
        End If
        Return
    End Sub

    Private Sub openSRplanarMap(ByVal sPlanar As String, ByRef oPlanar As PlanarClass)
        'retrieve Map Projection
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sParArray(29) As String 'map projection parameter array
        Dim s1 As String = ""
        Dim sProjInfo As String = ""
        Dim iSelIndex As Integer = 0
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sPlanar)
        sTitle = "Spatial Reference error"

        'retrieve Map Projection Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/mapprojn")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            oPlanar.MapProj = True
            oPlanar.MapProjName = s1
            sParArray(0) = s1
        Else
            Return
        End If

        'retrieve Map Projection parameter info using type in s1
        Select Case s1
            Case "Albers Conical Equal Area"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/albers")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAlbers(sProjInfo, sParArray, "albers")
                End If
            Case "Azimuthal Equidistant"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/azimequi")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAziEqui(sProjInfo, sParArray, "azimequi")
                End If
            Case "Equidistant Conic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/equicon")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAlbers(sProjInfo, sParArray, "equicon")
                End If
            Case "Equirectangular"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/equirect")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openEquiRect(sProjInfo, sParArray)
                End If
            Case "General Vertical Near-sided Projection"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/gvnsp")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGenVertPersp(sProjInfo, sParArray)
                End If
            Case "Gnomonic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/gnomonic")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGnomonic(sProjInfo, sParArray, "gnomonic")
                End If
            Case "Lambert Azimuthal Equal Area"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/lamberta")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGnomonic(sProjInfo, sParArray, "lamberta")
                End If
            Case "Lambert Conformal Conic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/lambertc")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAlbers(sProjInfo, sParArray, "lambertc")
                End If
            Case "Mercator"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/mercator")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openMercator(sProjInfo, sParArray)
                End If
            Case "Modified Stereographic for Alaska"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/modsak")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openModAlaska(sProjInfo, sParArray)
                End If
            Case "Miller Cylindrical"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/miller")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openMiller(sProjInfo, sParArray)
                End If
            Case "Oblique Mercator"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/obqmerc")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openObqMercator(sProjInfo, sParArray)
                End If
            Case "Orthographic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/orthogr")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGnomonic(sProjInfo, sParArray, "orthogr")
                End If
            Case "Polar Stereographic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/polarst")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openPolarStereo(sProjInfo, sParArray)
                End If
            Case "Polyconic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/polycon")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAziEqui(sProjInfo, sParArray, "polycon")
                End If
            Case "Robinson"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/robinson")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGnomonic(sProjInfo, sParArray, "robinson")
                End If
            Case "Sinusoidal"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/sinusoid")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAziEqui(sProjInfo, sParArray, "sinusoid")
                End If
            Case "Space Oblique Mercator"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/spaceobq")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openSpaceMercator(sProjInfo, sParArray)
                End If
            Case "Stereographic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/stereo")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openGnomonic(sProjInfo, sParArray, "stereo")
                End If
            Case "Transverse Mercator"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/transmer")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAziEqui(sProjInfo, sParArray, "transmer")
                End If
            Case "van der Grinten"
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/vdgrin")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).OuterXml
                    openAziEqui(sProjInfo, sParArray, "vdgrin")
                End If
            Case Else
                'other map projection system
                xmlNlist = xmlSpRefDoc.SelectNodes("/mapproj/otherprj")
                If (xmlNlist.Count > 0) Then
                    sProjInfo = xmlNlist(0).InnerText.Trim
                    sParArray(28) = sProjInfo
                End If
        End Select

        'update the parameter values
        iCount = 28
        For iLoop = 0 To iCount
            oPlanar.setParam(iLoop, sParArray(iLoop))
        Next
    End Sub

    Private Sub openAlbers(ByVal sAlbers As String, ByRef sParValues() As String, ByVal sType As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim sNode As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sAlbers)

        'retrieve up to 2 standard parallels
        sNode = "/" & sType & "/stdparll"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        iCount = xmlNlist.Count - 1
        If (iCount > 1) Then iCount = 1 'only 2 std parallels
        For iLoop = 0 To iCount
            sProjInfo = xmlNlist(iLoop).OuterXml
            openStdParallel(sProjInfo)
            sParValues(iLoop + 2) = sProjInfo
        Next
        'Longitude of Central Meridian
        sNode = "/" & sType & "/longcm"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'Latitude of Projection Origin
        sNode = "/" & sType & "/latprjo"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjOrig(sProjInfo)
            sParValues(5) = sProjInfo
        End If
        'False Easting
        sNode = "/" & sType & "/feast"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        sNode = "/" & sType & "/fnorth"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openAziEqui(ByVal sAziEqui As String, ByRef sParValues() As String, ByVal sType As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim sNode As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sAziEqui)

        'Longitude of Central Meridian
        sNode = "/" & sType & "/longcm"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'Latitude of Projection Origin
        sNode = "/" & sType & "/latprjo"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjOrig(sProjInfo)
            sParValues(5) = sProjInfo
        End If
        'False Easting
        sNode = "/" & sType & "/feast"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        sNode = "/" & sType & "/fnorth"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If

        If (sType = "transmer") Then
            'Scale Factor at Central Meridian
            sNode = "/" & sType & "/sfctrmer"
            xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
            If (xmlNlist.Count > 0) Then
                sProjInfo = xmlNlist(0).OuterXml
                openScaleCentMerid(sProjInfo)
                sParValues(23) = sProjInfo
            End If
        End If
    End Sub

    Private Sub openEquiConic(ByVal sEquiConic As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sEquiConic)

        'retrieve up to 2 standard parallels
        xmlNlist = xmlSpRefDoc.SelectNodes("/equicon/stdparll")
        iCount = xmlNlist.Count - 1
        If (iCount > 1) Then iCount = 1 'only 2 std parallels
        For iLoop = 0 To iCount
            sProjInfo = xmlNlist(iLoop).OuterXml
            openStdParallel(sProjInfo)
            sParValues(iLoop + 2) = sProjInfo
        Next
        'Longitude of Central Meridian
        xmlNlist = xmlSpRefDoc.SelectNodes("/equicon/longcm")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'Latitude of Projection Origin
        xmlNlist = xmlSpRefDoc.SelectNodes("/equicon/latprjo")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjOrig(sProjInfo)
            sParValues(5) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/equicon/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/equicon/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openEquiRect(ByVal sEquiRect As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sEquiRect)

        'retrieve up to 1 standard parallel
        xmlNlist = xmlSpRefDoc.SelectNodes("/equirect/stdparll")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openStdParallel(sProjInfo)
            sParValues(2) = sProjInfo
        End If
        'Longitude of Central Meridian
        xmlNlist = xmlSpRefDoc.SelectNodes("/equirect/longcm")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/equirect/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/equirect/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openGenVertPersp(ByVal sGVNP As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sGVNP)

        'retrieve Height Above Perspective Point
        xmlNlist = xmlSpRefDoc.SelectNodes("/gvnsp/heightpt")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openHtPersPoint(sProjInfo)
            sParValues(9) = sProjInfo
        End If
        'Longitude of Projection Center
        xmlNlist = xmlSpRefDoc.SelectNodes("/gvnsp/longpc")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongProjCent(sProjInfo)
            sParValues(10) = sProjInfo
        End If
        'Latitude of Projection Center
        xmlNlist = xmlSpRefDoc.SelectNodes("/gvnsp/latprjc")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjCent(sProjInfo)
            sParValues(11) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/gvnsp/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/gvnsp/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openGnomonic(ByVal sGnomonic As String, ByRef sParValues() As String, ByVal sType As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim sNode As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sGnomonic)

        'Longitude of Projection Center
        sNode = "/" & sType & "/longpc"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongProjCent(sProjInfo)
            sParValues(10) = sProjInfo
        End If
        'Latitude of Projection Center
        sNode = "/" & sType & "/latprjc"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjCent(sProjInfo)
            sParValues(11) = sProjInfo
        End If
        'False Easting
        sNode = "/" & sType & "/feast"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        sNode = "/" & sType & "/fnorth"
        xmlNlist = xmlSpRefDoc.SelectNodes(sNode)
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openMercator(ByVal sMercator As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sMercator)

        'Longitude of Central Meridian
        xmlNlist = xmlSpRefDoc.SelectNodes("/mercator/longcm")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/mercator/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/mercator/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If

        'retrieve Standard Parallel
        xmlNlist = xmlSpRefDoc.SelectNodes("/mercator/stdparll")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(iLoop).OuterXml
            openStdParallel(sProjInfo)
            sParValues(2) = sProjInfo
            Return
        End If
        ' OR retrieve Scale Factor at Equator
        xmlNlist = xmlSpRefDoc.SelectNodes("/mercator/sfequat")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openScaleEquator(sProjInfo)
            sParValues(8) = sProjInfo
        End If
    End Sub

    Private Sub openModAlaska(ByVal sModAlaska As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sModAlaska)

        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/modsak/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/modsak/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openMiller(ByVal sMiller As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sMiller)

        'Longitude of Central Meridian
        xmlNlist = xmlSpRefDoc.SelectNodes("/miller/longcm")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLongCentMerid(sProjInfo)
            sParValues(4) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/miller/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/miller/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openObqMercator(ByVal sMercator As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim sVal1(2) As String
        Dim sVal2(2) As String
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sMercator)

        'Scale Factor at Center Line
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqmerc/sfctrlin")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openScaleCentLine(sProjInfo)
            sParValues(12) = sProjInfo
        End If
        'Latitude of Projection Origin
        xmlNlist = xmlSpRefDoc.SelectNodes("obqmerc/latprjo")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLatProjOrig(sProjInfo)
            sParValues(5) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqmerc/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqmerc/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If

        'Oblique Line Azimuth
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqmerc/obqlazim")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(iLoop).OuterXml
            openObqAzimuth(sProjInfo, sVal1(0), sVal1(1))
            sParValues(13) = sVal1(0)
            sParValues(14) = sVal1(1)
            Return
        End If
        'OR Oblique Line Point
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqmerc/obqlpt")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openObqLinePt(sProjInfo, sVal1, sVal2)
            sParValues(15) = sVal1(0) 'Oblique Line Latitude 1
            sParValues(16) = sVal2(0) 'Oblique Line Longitude 1
            sParValues(17) = sVal1(1) 'Oblique Line Latitude 2
            sParValues(18) = sVal2(1) 'Oblique Line Longitude 2
        End If
    End Sub

    Private Sub openPolarStereo(ByVal sPolar As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0

        xmlSpRefDoc.LoadXml(sPolar)

        'Straight Vertical Longitude
        xmlNlist = xmlSpRefDoc.SelectNodes("/polarst/svlong")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openStraightLongPole(sProjInfo)
            sParValues(19) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/polarst/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/polarst/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If

        'Standard Parallel
        xmlNlist = xmlSpRefDoc.SelectNodes("polarst/stdparll")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openStdParallel(sProjInfo)
            sParValues(2) = sProjInfo
            Return
        End If
        'OR Scale Factor at Projection Origin
        xmlNlist = xmlSpRefDoc.SelectNodes("/polarst/sfprjorg")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openScaleProjOrig(sProjInfo)
            sParValues(20) = sProjInfo
        End If
    End Sub

    Private Sub openSpaceMercator(ByVal sMercator As String, ByRef sParValues() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim sProjInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0

        xmlSpRefDoc.LoadXml(sMercator)

        'Landsat Number
        xmlNlist = xmlSpRefDoc.SelectNodes("/spaceobq/landsat")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openLandsat(sProjInfo)
            sParValues(21) = sProjInfo
        End If
        'Path Number
        xmlNlist = xmlSpRefDoc.SelectNodes("/spaceobq/pathnum")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openPathNumber(sProjInfo)
            sParValues(22) = sProjInfo
        End If
        'False Easting
        xmlNlist = xmlSpRefDoc.SelectNodes("/spaceobq/feast")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Easting")
            sParValues(6) = sProjInfo
        End If
        'False Northing
        xmlNlist = xmlSpRefDoc.SelectNodes("/spaceobq/fnorth")
        If (xmlNlist.Count > 0) Then
            sProjInfo = xmlNlist(0).OuterXml
            openEastNorth(sProjInfo, "Northing")
            sParValues(7) = sProjInfo
        End If
    End Sub

    Private Sub openStdParallel(ByRef sParallel As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sParallel)
        s1 = xmlSpRefDoc.SelectSingleNode("stdparll").InnerText.Trim

        'check to make sure value is real number between -90 and 90
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 90.0) Then
                sError = "Standard parallel of " & s1 & " exceeds maximum of 90.0." & CrLf
                sError += "Value truncated to 90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "90.0"
            ElseIf (rVal < -90.0) Then
                sError = "Standard parallel of " & s1 & " exceeds minimum of -90.0." & CrLf
                sError += "Value truncated to -90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "-90.0"
            Else
                'satisfactory value
                sParallel = s1
            End If
        Else
            sError = "Standard parallel of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sParallel = ""
        End If
    End Sub

    Private Sub openLongCentMerid(ByRef sMerid As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sMerid)
        s1 = xmlSpRefDoc.SelectSingleNode("longcm").InnerText.Trim

        'check to make sure value is real number between -180 and 180
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal >= 180.0) Then
                sError = "Longitude of Central Meridian of " & s1 & " exceeds maximum of 180.0." & CrLf
                sError += "Value truncated to 179.99999"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sMerid = "179.99999"
            ElseIf (rVal < -180.0) Then
                sError = "Longitude of Central Meridian of " & s1 & " exceeds minimum of -180.0." & CrLf
                sError += "Value truncated to -180.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sMerid = "-180.0"
            Else
                'satisfactory value
                sMerid = s1
            End If
        Else
            sError = "Longitude of Central Meridian of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sMerid = ""
        End If
    End Sub

    Private Sub openLatProjOrig(ByRef sParallel As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sParallel)
        s1 = xmlSpRefDoc.SelectSingleNode("latprjo").InnerText.Trim

        'check to make sure value is real number between -90 and 90
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 90.0) Then
                sError = "Latitude of Projection Origin of " & s1 & " exceeds maximum of 90.0." & CrLf
                sError += "Value truncated to 90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "90.0"
            ElseIf (rVal < -90.0) Then
                sError = "Latitude of Projection Origin of " & s1 & " exceeds minimum of -90.0." & CrLf
                sError += "Value truncated to -90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "-90.0"
            Else
                'satisfactory value
                sParallel = s1
            End If
        Else
            sError = "Latitude of Projection Origin of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sParallel = ""
        End If
    End Sub

    Private Sub openEastNorth(ByRef sRealVal As String, ByVal sDir As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        Select Case sDir
            Case "Easting"
                s1 = xmlSpRefDoc.SelectSingleNode("feast").InnerText.Trim
            Case "Northing"
                s1 = xmlSpRefDoc.SelectSingleNode("fnorth").InnerText.Trim
        End Select

        'check to make sure value is real number between -500,000,000 and 500,000,000
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500000000.0) Then
                sError = "False " & sDir & " of " & s1 & " exceeds maximum of 500,000,000.0." & CrLf
                sError += "Value truncated to 500,000,000.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500000000.0"
            ElseIf (rVal < -500000000.0) Then
                sError = "False " & sDir & " of " & s1 & " exceeds minimum of -500,000,000.0." & CrLf
                sError += "Value truncated to -500,000,000.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "-5000000000.0"
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "False " & sDir & " of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openHtPersPoint(ByRef sRealVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        s1 = xmlSpRefDoc.SelectSingleNode("heightpt").InnerText.Trim

        'check to make sure value is real number between -500,000,000 and 500,000,000
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500000000.0) Then
                sError = "Height Above Perspective Point of " & s1 & " exceeds maximum of 500,000,000.0." & CrLf
                sError += "Value truncated to 500,000,000.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500000000.0"
            ElseIf (rVal < -500000000.0) Then
                sError = "Height Above Perspective Point of " & s1 & " exceeds minimum of -500,000,000.0." & CrLf
                sError += "Value truncated to -500,000,000.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "-5000000000.0"
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "Height Above Perspective Point of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openLongProjCent(ByRef sLongProjCent As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sLongProjCent)
        s1 = xmlSpRefDoc.SelectSingleNode("longpc").InnerText.Trim

        'check to make sure value is real number between -180 and 180
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal >= 180.0) Then
                sError = "Longitude of Projection Center of " & s1 & " exceeds maximum of 180.0." & CrLf
                sError += "Value truncated to 179.99999"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sLongProjCent = "179.99999"
            ElseIf (rVal < -180.0) Then
                sError = "Longitude of Projection Center of " & s1 & " exceeds minimum of -180.0." & CrLf
                sError += "Value truncated to -180.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sLongProjCent = "-180.0"
            Else
                'satisfactory value
                sLongProjCent = s1
            End If
        Else
            sError = "Longitude of Projection Center of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sLongProjCent = ""
        End If
    End Sub

    Private Sub openLatProjCent(ByRef sParallel As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sParallel)
        s1 = xmlSpRefDoc.SelectSingleNode("latprjc").InnerText.Trim

        'check to make sure value is real number between -90 and 90
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 90.0) Then
                sError = "Latitude of Projection Center of " & s1 & " exceeds maximum of 90.0." & CrLf
                sError += "Value truncated to 90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "90.0"
            ElseIf (rVal < -90.0) Then
                sError = "Latitude of Projection Center of " & s1 & " exceeds minimum of -90.0." & CrLf
                sError += "Value truncated to -90.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sParallel = "-90.0"
            Else
                'satisfactory value
                sParallel = s1
            End If
        Else
            sError = "Latitude of Projection Center of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sParallel = ""
        End If
    End Sub

    Private Sub openScaleEquator(ByRef sRealVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        s1 = xmlSpRefDoc.SelectSingleNode("sfequat").InnerText.Trim

        'check to make sure value is real number between 0 and 500
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500.0) Then
                sError = "Scale Factor at Equator of " & s1 & " exceeds maximum of 500.0." & CrLf
                sError += "Value truncated to 500.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500.0"
            ElseIf (rVal < 0.0) Then
                sError = "Scale Factor at Equator of " & s1 & " < 0.0." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = ""
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "Scale Factor at Equator of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openScaleCentLine(ByRef sRealVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        s1 = xmlSpRefDoc.SelectSingleNode("sfctrlin").InnerText.Trim

        'check to make sure value is real number between 0 and 500
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500.0) Then
                sError = "Scale Factor at Center Line of " & s1 & " exceeds maximum of 500.0." & CrLf
                sError += "Value truncated to 500.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500.0"
            ElseIf (rVal < 0.0) Then
                sError = "Scale Factor at Center Line of " & s1 & " < 0.0." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = ""
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "Scale Factor at Center Line of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openObqAzimuth(ByVal sAzimuth As String, ByRef sAngle As String, ByRef sLong As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sAzimuth)
        sAngle = ""
        sLong = ""

        'Azimuthal Angle
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqlazim/azimangl")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            'check to make sure value is real number between 0 and 360
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal >= 360.0) Then
                    sError = "Azimuthal Angle of " & s1 & " exceeds maximum of 360.0." & CrLf
                    sError += "Value truncated to 359.99999"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sAngle = "359.99999"
                ElseIf (rVal < 0.0) Then
                    sError = "Azimuthal Angle of " & s1 & " < 0.0." & CrLf
                    sError += "Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sAngle = ""
                Else
                    'satisfactory value
                    sAngle = s1
                End If
            Else
                sError = "Azimuthal Angle of " & s1 & " could not be converted to a number."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sAngle = ""
            End If
        End If
        'Azimuth Measure Point Longitude
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqlazim/azimptl")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            'check to make sure value is real number between -180 and 180
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal >= 180.0) Then
                    sError = "Azimuth Measure Point Longitude of " & s1 & " exceeds maximum of 180.0." & CrLf
                    sError += "Value truncated to 179.99999"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLong = "179.99999"
                ElseIf (rVal < -180.0) Then
                    sError = "Azimuth Measure Point Longitude of " & s1 & " exceeds minimum of -180.0." & CrLf
                    sError += "Value truncated to -180.0"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLong = "-180.0"
                Else
                    'satisfactory value
                    sLong = s1
                End If
            Else
                sError = "Azimuth Measure Point Longitude of " & s1 & " could not be converted to a number."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sLong = ""
            End If
        End If
    End Sub

    Private Sub openObqLinePt(ByVal sLinePt As String, ByRef sLat() As String, ByRef sLong() As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sLinePt)
        'initialize return variables
        sLat(0) = "" : sLat(1) = ""
        sLong(0) = "" : sLong(1) = ""

        'Oblique Line Latitudes
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqlpt/obqllat")
        iCount = xmlNlist.Count - 1
        If (iCount > 1) Then iCount = 1 'only 2 latitudes maximum
        For iLoop = 0 To iCount
            s1 = xmlNlist(iLoop).InnerText.Trim
            'check to make sure value is real number between -90 and 90
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal > 90.0) Then
                    sError = "Oblique Line Latitude of " & s1 & " exceeds maximum of 90.0." & CrLf
                    sError += "Value truncated to 90.0"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLat(iLoop) = "90.0"
                ElseIf (rVal < -90.0) Then
                    sError = "Oblique Line Latitude of " & s1 & " exceeds minimum of -90.0." & CrLf
                    sError += "Value truncated to -90.0"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLat(iLoop) = "-90.0"
                Else
                    'satisfactory value
                    sLat(iLoop) = s1
                End If
            Else
                sError = "Oblique Line Latitude of " & s1 & " could not be converted to a number."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sLat(iLoop) = ""
            End If
        Next
        'Oblique Line Longitude
        xmlNlist = xmlSpRefDoc.SelectNodes("/obqlpt/obqllong")
        iCount = xmlNlist.Count - 1
        If (iCount > 1) Then iCount = 1 'only 2 longitudes maximum
        For iLoop = 0 To iCount
            s1 = xmlNlist(iLoop).InnerText.Trim
            'check to make sure value is real number between -180 and 180
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal >= 180.0) Then
                    sError = "Oblique Line Longitude of " & s1 & " exceeds maximum of 180.0." & CrLf
                    sError += "Value truncated to 179.99999"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLong(iLoop) = "179.99999"
                ElseIf (rVal < -180.0) Then
                    sError = "Oblique Line Longitude of " & s1 & " exceeds minimum of -180.0." & CrLf
                    sError += "Value truncated to -180.0"
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    sLong(iLoop) = "-180.0"
                Else
                    'satisfactory value
                    sLong(iLoop) = s1
                End If
            Else
                sError = "Oblique Line Longitude of " & s1 & " could not be converted to a number."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sLong(iLoop) = ""
            End If
        Next
    End Sub

    Private Sub openStraightLongPole(ByRef sPole As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sPole)
        s1 = xmlSpRefDoc.SelectSingleNode("svlong").InnerText.Trim

        'check to make sure value is real number between -180 and 180
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal >= 180.0) Then
                sError = "Straight Vertical Longitude from Pole of " & s1 & " exceeds maximum of 180.0." & CrLf
                sError += "Value truncated to 179.99999"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sPole = "179.99999"
            ElseIf (rVal < -180.0) Then
                sError = "Straight Vertical Longitude from Pole of " & s1 & " exceeds minimum of -180.0." & CrLf
                sError += "Value truncated to -180.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sPole = "-180.0"
            Else
                'satisfactory value
                sPole = s1
            End If
        Else
            sError = "Straight Vertical Longitude from Pole of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sPole = ""
        End If
    End Sub

    Private Sub openScaleProjOrig(ByRef sRealVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        s1 = xmlSpRefDoc.SelectSingleNode("sfprjorg").InnerText.Trim

        'check to make sure value is real number between 0 and 500
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500.0) Then
                sError = "Scale Factor at Projection Origin of " & s1 & " exceeds maximum of 500.0." & CrLf
                sError += "Value truncated to 500.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500.0"
            ElseIf (rVal < 0.0) Then
                sError = "Scale Factor at Projection Origin of " & s1 & " < 0.0." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = ""
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "Scale Factor at Projection Origin of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openLandsat(ByRef sIntegerVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iVal As Integer = 0
        Dim bCheck As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sIntegerVal)
        s1 = xmlSpRefDoc.SelectSingleNode("landsat").InnerText.Trim

        'check to make sure value is integer number between 0 and 50
        chkInteger(s1, iVal, bCheck)
        If (bCheck = True) Then
            If (iVal > 50) Then
                sError = "Landsat of " & s1 & " exceeds maximum of 50." & CrLf
                sError += "Value truncated to 50."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "50"
            ElseIf (iVal < 0) Then
                sError = "Landsat of " & s1 & " is < 0." & CrLf
                sError += "Value truncated to 0."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "0"
            Else
                'satisfactory value
                sIntegerVal = s1
            End If
        Else
            sError = "Landsat of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
        End If
    End Sub

    Private Sub openPathNumber(ByRef sIntegerVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iVal As Integer = 0
        Dim bCheck As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sIntegerVal)
        s1 = xmlSpRefDoc.SelectSingleNode("pathnum").InnerText.Trim

        'check to make sure value is integer number between 0 and 500
        chkInteger(s1, iVal, bCheck)
        If (bCheck = True) Then
            If (iVal > 50) Then
                sError = "Path Number of " & s1 & " exceeds maximum of 500." & CrLf
                sError += "Value truncated to 500."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "500"
            ElseIf (iVal < 0) Then
                sError = "Path Number of " & s1 & " is < 0." & CrLf
                sError += "Value truncated to 0."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "0"
            Else
                'satisfactory value
                sIntegerVal = s1
            End If
        Else
            sError = "Path Number of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
        End If
    End Sub

    Private Sub openScaleCentMerid(ByRef sRealVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sRealVal)
        s1 = xmlSpRefDoc.SelectSingleNode("sfctrmer").InnerText.Trim

        'check to make sure value is real number between 0 and 500
        realCheck(s1, rVal, bReal)
        If (bReal = True) Then
            If (rVal > 500.0) Then
                sError = "Scale Factor at Center Meridian of " & s1 & " exceeds maximum of 500.0." & CrLf
                sError += "Value truncated to 500.0"
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = "500.0"
            ElseIf (rVal < 0.0) Then
                sError = "Scale Factor at Center Meridian of " & s1 & " < 0.0." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sRealVal = ""
            Else
                'satisfactory value
                sRealVal = s1
            End If
        Else
            sError = "Scale Factor at Center Meridian of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sRealVal = ""
        End If
    End Sub

    Private Sub openSRplanarGrid(ByVal sPlanar As String, ByRef oPlanar As PlanarClass)
        'retrieve Grid Coordinate System
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sParArray(29) As String 'map projection parameter array
        Dim sProjInfo As String = ""
        Dim s1 As String = ""
        Dim iSelIndex As Integer = 0
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim i1 As Integer = 0
        Dim i2 As Integer = 0
        Dim i3 As Integer = 0
        Dim i4 As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sPlanar)
        sTitle = "Spatial Reference error"

        'retrieve Grid System Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/gridsysn")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            oPlanar.GridSys = True
            oPlanar.GridName = s1
            sParArray(0) = s1
        Else
            Return
        End If

        'retrieve Map Projection parameter info using type in s1
        'begin grid systems
        Select Case s1
            Case "Universal Transverse Mercator"
                xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/utm")
                If (xmlNlist.Count > 0) Then
                    'UTM Zone Number
                    xmlPlist = xmlNlist(0).SelectNodes("utmzone")
                    If (xmlPlist.Count > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openUTMzone(sProjInfo)
                        sParArray(24) = sProjInfo
                    End If
                    'Transverse Mercator
                    xmlPlist = xmlNlist(0).SelectNodes("transmer")
                    If (xmlPlist.Count > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openAziEqui(sProjInfo, sParArray, "transmer")
                    End If
                End If
            Case "Universal Polar Stereographic"
                xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/ups")
                If (xmlNlist.Count > 0) Then
                    'UPS Zone Identifier
                    xmlPlist = xmlNlist(0).SelectNodes("upszone")
                    If (xmlPlist.Count > 0) Then
                        s1 = xmlPlist(0).InnerText.Trim
                        If (s1 = "A" Or s1 = "B" Or s1 = "Y" Or s1 = "Z") Then
                            sParArray(25) = s1
                        Else
                            sParArray(25) = ""
                        End If
                    End If
                    'Polar Stereographic
                    xmlPlist = xmlNlist(0).SelectNodes("polarst")
                    If (xmlPlist.Count > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openPolarStereo(sProjInfo, sParArray)
                    End If
                End If
            Case "State Plane Coordinate System 1927", "State Plane Coordinate System 1983"
                xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/spcs")
                If (xmlNlist.Count > 0) Then
                    'SPCS Zone Identifier
                    xmlPlist = xmlNlist(0).SelectNodes("spcszone")
                    If (xmlPlist.Count > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openSPCSzone(sProjInfo)
                        sParArray(26) = sProjInfo
                    End If
                    'select 1 of 4 possible projections
                    xmlPlist = xmlNlist(0).SelectNodes("lambertc")
                    i1 = xmlPlist.Count
                    If (i1 > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openAlbers(sProjInfo, sParArray, "lambertc")
                        sParArray(1) = "Lambert Conformal Conic"
                    Else
                        xmlPlist = xmlNlist(0).SelectNodes("transmer")
                        i2 = xmlPlist.Count
                        If (i2 > 0) Then
                            sProjInfo = xmlPlist(0).OuterXml
                            openAziEqui(sProjInfo, sParArray, "transmer")
                            sParArray(1) = "Transverse Mercator"
                        Else
                            xmlPlist = xmlNlist(0).SelectNodes("obqmerc")
                            i3 = xmlPlist.Count
                            If (i3 > 0) Then
                                sProjInfo = xmlPlist(0).OuterXml
                                openObqMercator(sProjInfo, sParArray)
                                sParArray(1) = "Oblique Mercator"
                            Else
                                xmlPlist = xmlNlist(0).SelectNodes("polycon")
                                i4 = xmlPlist.Count
                                If (i4 > 0) Then
                                    sProjInfo = xmlPlist(0).OuterXml
                                    openAziEqui(sProjInfo, sParArray, "polycon")
                                    sParArray(1) = "Polyconic"
                                End If
                            End If
                        End If
                    End If
                End If
            Case "ARC Coordinate System"
                xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/arcsys")
                If (xmlNlist.Count > 0) Then
                    'ARC System Zone Identifier
                    xmlPlist = xmlNlist(0).SelectNodes("arczone")
                    If (xmlPlist.Count > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openARCzone(sProjInfo)
                        sParArray(27) = sProjInfo
                    End If
                    'select 1 of 2 possible projections
                    xmlPlist = xmlNlist(0).SelectNodes("equirect")
                    i1 = xmlPlist.Count
                    If (i1 > 0) Then
                        sProjInfo = xmlPlist(0).OuterXml
                        openEquiRect(sProjInfo, sParArray)
                        sParArray(1) = "Equirectangular"
                    Else
                        xmlPlist = xmlNlist(0).SelectNodes("azimequi")
                        i2 = xmlPlist.Count
                        If (i2 > 0) Then
                            sProjInfo = xmlPlist(0).OuterXml
                            openAziEqui(sProjInfo, sParArray, "azimequi")
                            sParArray(1) = "Azimuthal Equidistant"
                        End If
                    End If
                End If
            Case "other grid system"
                xmlNlist = xmlSpRefDoc.SelectNodes("/gridsys/othergrd")
                If (xmlNlist.Count > 0) Then
                    'Other Grid System Definition
                    sParArray(28) = xmlNlist(0).InnerText.Trim
                End If
        End Select

        'update the parameter values
        iCount = 28
        For iLoop = 0 To iCount
            oPlanar.setParam(iLoop, sParArray(iLoop))
        Next
    End Sub

    Private Sub openUTMzone(ByRef sIntegerVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iVal As Integer = 0
        Dim bCheck As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sIntegerVal)
        s1 = xmlSpRefDoc.SelectSingleNode("utmzone").InnerText.Trim

        'check to make sure value is integer number between -60 and 60
        chkInteger(s1, iVal, bCheck)
        If (bCheck = True) Then
            If (iVal > 60) Then
                sError = "UTM Zone Number of " & s1 & " exceeds maximum of 60." & CrLf
                sError += "Value truncated to 60."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "60"
            ElseIf (iVal < -60) Then
                sError = "UTM Zone Number of " & s1 & " below minimum of -60." & CrLf
                sError += "Value truncated to -60."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "0"
            Else
                'satisfactory value
                sIntegerVal = s1
            End If
        Else
            sError = "UTM Zone Number of " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
        End If
    End Sub

    Private Sub openSPCSzone(ByRef sIntegerVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iVal As Integer = 0
        Dim bCheck As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sIntegerVal)
        s1 = xmlSpRefDoc.SelectSingleNode("spcszone").InnerText.Trim

        'check to make sure the string length is 4
        If (s1.Length = 4) Then
            'continue processing
        ElseIf (s1.Length < 4) Then
            sError = "SPCS Zone Identifier " & s1 & " is too short; it needs a 4 digit identifier." & CrLf
            sError += "Value left blank."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
            Return
        Else
            sError = "SPCS Zone Identifier " & s1 & " contains characters besides the expected 4 digit identifier." & CrLf
            sError += "Value left blank."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
            Return
        End If

        'check to make sure value is integer number between 0 and 9999
        chkInteger(s1, iVal, bCheck)
        If (bCheck = True) Then
            If (iVal > 9999) Then ' this should not ever happen because of 4-character limit
                sError = "SPCS Zone Identifier " & s1 & " exceeds maximum of 9999." & CrLf
                sError += "Value truncated to 9999."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "9999"
            ElseIf (iVal < 0) Then
                sError = "SPCS Zone Identifier " & s1 & " below minimum of 0." & CrLf
                sError += "Value left blank."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = ""
            Else
                'satisfactory value
                sIntegerVal = s1
            End If
        Else
            sError = "SPCS Zone Identifier " & s1 & " could not be converted to a number." & CrLf
            sError += "Value left blank."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
        End If
    End Sub

    Private Sub openARCzone(ByRef sIntegerVal As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iVal As Integer = 0
        Dim bCheck As Boolean = False

        s1 = ""
        sTitle = "Retrieval of Map Projection parameters"
        xmlSpRefDoc.LoadXml(sIntegerVal)
        s1 = xmlSpRefDoc.SelectSingleNode("arczone").InnerText.Trim

        'check to make sure value is integer number between 1 and 18
        chkInteger(s1, iVal, bCheck)
        If (bCheck = True) Then
            If (iVal > 18) Then
                sError = "ARC System Zone Idenfier " & s1 & " exceeds maximum of 18." & CrLf
                sError += "Value set to 18."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "18"
            ElseIf (iVal < 1) Then
                sError = "ARC System Zone Idenfier " & s1 & " below minimum of 1." & CrLf
                sError += "Value set to 1."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                sIntegerVal = "1"
            Else
                'satisfactory value
                sIntegerVal = s1
            End If
        Else
            sError = "ARC System Zone Idenfier " & s1 & " could not be converted to a number."
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            sIntegerVal = ""
        End If
    End Sub

    Private Sub openSRplanarUpdate(ByVal oplanar As PlanarClass)
        Dim s1 As String = ""

        'update display list box
        If (oplanar.MapProj = True) Then
            s1 = "Map: " & oplanar.MapProjName
        ElseIf (oplanar.GridSys = True) Then
            s1 = "Grid: " & oplanar.GridName
            If (oplanar.GridName <> "other grid system") Then
                s1 += ", Projection: " & oplanar.GridProjName
            End If
        Else
            s1 = "Local Planar: " & Microsoft.VisualBasic.Left(oplanar.LocalDesc, 40)
        End If
        f41.lboxPlanar.Items.Add(s1)

        'update the main collection
        f41.cPlanar.Add(oplanar)
    End Sub

    Private Sub openSRgeodetic(ByVal sGeodetic As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sGeodetic)
        sTitle = "Spatial Reference error"

        'retrieve Horizontal Datum Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/geodetic/horizdn")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put datum name into combo box display
                iCount = f41.cboxHorizName.FindStringExact(s1)
                If (iCount = -1) Then
                    f41.cboxHorizName.Items.Add(s1)
                    f41.cboxHorizName.SelectedIndex = f41.cboxHorizName.Items.Count - 1
                Else
                    f41.cboxHorizName.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Ellipsoid Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/geodetic/ellips")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put ellipsoid name into combo box display
                iCount = f41.cboxEllipsoid.FindStringExact(s1)
                If (iCount = -1) Then
                    f41.cboxEllipsoid.Items.Add(s1)
                    f41.cboxEllipsoid.SelectedIndex = f41.cboxEllipsoid.Items.Count - 1
                Else
                    f41.cboxEllipsoid.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Semi-major Axis
        xmlNlist = xmlSpRefDoc.SelectNodes("/geodetic/semiaxis")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(iLoop).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal > 6500000.0) Then
                    sError = "Geodetic Model" & CrLf
                    sError += "Semi-major Axis, " & s1 & ", is too large for the control."
                    sError += "Value reduced to 6,500,000."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    rVal = 6500000.0
                End If
                If (rVal >= 0.0) Then
                    f41.numSemiMajor.Value = Convert.ToDecimal(rVal) 'place value into control
                Else
                    sError = "Geodetic Model" & CrLf
                    sError += "Semi-major Axis, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Geodetic Model" & CrLf
                sError += "Semi-major Axis, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        'retrieve Denominator of Flattening Ratio
        xmlNlist = xmlSpRefDoc.SelectNodes("/geodetic/denflat")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(iLoop).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal > 400.0) Then
                    sError = "Geodetic Model" & CrLf
                    sError += "Denominator of Flattening Ratio, " & s1 & ", is too large for the control."
                    sError += "Value reduced to 400."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    rVal = 400.0
                End If
                If (rVal >= 0.0) Then
                    f41.numFlatten.Value = Convert.ToDecimal(rVal) 'place value into control
                Else
                    sError = "Geodetic Model" & CrLf
                    sError += "Denominator of Flattening Ratio, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Geodetic Model" & CrLf
                sError += "Denominator of Flattening Ratio, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If
    End Sub

    Private Sub openSRaltitude(ByVal sAltitude As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sAltitude)
        sTitle = "Spatial Reference error"

        'retrieve Altitude Datum Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/altsys/altdatum")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put datum name into combo box display
                iCount = f42.cboxAltDatum.FindStringExact(s1)
                If (iCount = -1) Then
                    f42.cboxAltDatum.Items.Add(s1)
                    f42.cboxAltDatum.SelectedIndex = f42.cboxAltDatum.Items.Count - 1
                Else
                    f42.cboxAltDatum.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Altitude Resolution
        xmlNlist = xmlSpRefDoc.SelectNodes("/altsys/altres")
        iCount = xmlNlist.Count
        sList = ""
        For iLoop = 0 To iCount - 1
            s1 = xmlNlist(iLoop).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal >= 0.0) Then
                    sList += s1 & sKdelim 'append new resolution to string
                Else
                    sError = "Altitude System Definition" & CrLf
                    sError += "Altitude Resolution, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Altitude System Definition" & CrLf
                sError += "Altitude Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Next
        f42.txtAltRes.Text = sList 'put collection of resolutions into text box

        'retrieve Altitude Distance Units
        xmlNlist = xmlSpRefDoc.SelectNodes("/altsys/altunits")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put distance units into combo box display
                iCount = f42.cboxAltUnits.FindStringExact(s1)
                If (iCount = -1) Then
                    f42.cboxAltUnits.Items.Add(s1)
                    f42.cboxAltUnits.SelectedIndex = f42.cboxAltUnits.Items.Count - 1
                Else
                    f42.cboxAltUnits.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Altitude Encoding Method
        xmlNlist = xmlSpRefDoc.SelectNodes("/altsys/altenc")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            'select encoding method for combo box display
            iCount = f42.cboxAltEncode.FindStringExact(s1)
            f42.cboxAltEncode.SelectedIndex = iCount
        End If
    End Sub

    Private Sub openSRdepth(ByVal sDepth As String)
        Dim xmlSpRefDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False

        xmlSpRefDoc.LoadXml(sDepth)
        sTitle = "Spatial Reference error"

        'retrieve Depth Datum Name
        xmlNlist = xmlSpRefDoc.SelectNodes("/depthsys/depthdn")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put datum name into combo box display
                iCount = f42.cboxDepthDatum.FindStringExact(s1)
                If (iCount = -1) Then
                    f42.cboxDepthDatum.Items.Add(s1)
                    f42.cboxDepthDatum.SelectedIndex = f42.cboxDepthDatum.Items.Count - 1
                Else
                    f42.cboxDepthDatum.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Depth Resolution
        xmlNlist = xmlSpRefDoc.SelectNodes("/depthsys/depthres")
        iCount = xmlNlist.Count
        sList = ""
        For iLoop = 0 To iCount - 1
            s1 = xmlNlist(iLoop).InnerText.Trim
            realCheck(s1, rVal, bReal)
            If (bReal = True) Then
                If (rVal >= 0.0) Then
                    sList += s1 & sKdelim 'append new resolution to string
                Else
                    sError = "Depth System Definition" & CrLf
                    sError += "Depth Resolution, " & s1 & ", less than 0. Value ignored."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If
            Else
                sError = "Depth System Definition" & CrLf
                sError += "Depth Resolution, " & s1 & ", could not be converted to a real number." & CrLf
                sError += "Value ignored."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Next
        f42.txtDepthRes.Text = sList 'put collection of resolutions into text box

        'retrieve Depth Distance Units
        xmlNlist = xmlSpRefDoc.SelectNodes("/depthsys/depthdu")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "") Then
                'do nothing
            Else
                'put distance units into combo box display
                iCount = f42.cboxDepthUnits.FindStringExact(s1)
                If (iCount = -1) Then
                    f42.cboxDepthUnits.Items.Add(s1)
                    f42.cboxDepthUnits.SelectedIndex = f42.cboxDepthUnits.Items.Count - 1
                Else
                    f42.cboxDepthUnits.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Depth Encoding Method
        xmlNlist = xmlSpRefDoc.SelectNodes("/depthsys/depthem")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            'select encoding method for combo box display
            iCount = f42.cboxDepthEncode.FindStringExact(s1)
            f42.cboxDepthEncode.SelectedIndex = iCount
        End If
    End Sub

    Private Sub realCheck(ByVal s1 As String, ByRef rValue As Double, ByRef bTrans As Boolean)
        Try
            bTrans = True
            rValue = Convert.ToDouble(s1)
        Catch ex As Exception
            bTrans = False
            rValue = 0.0
        End Try
    End Sub

#End Region

#Region " DOM processing for Entity & Attribute Information section "

    Private Sub openEA(ByVal xmlOpenEA As XmlDocument)
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sEAinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim jCount As Integer = 0

        'retrieve Overview Description(s)
        xmlNlist = xmlOpenEA.SelectNodes("/eainfo/overview")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            sEAinfo = xmlNlist(iLoop).OuterXml
            openEAover(sEAinfo)
        Next

        'retrieve Detailed Description(s)
        xmlNlist = xmlOpenEA.SelectNodes("/eainfo/detailed")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            'sEAinfo = xmlNlist(iLoop).OuterXml
            'openEAdetail(sEAinfo)
            openEAdetail(xmlNlist(iLoop))
        Next
        'set selected index for entities, attributes, and domains to 0
        'If (cboxEntity.Items.Count > 0) Then cboxEntity.SelectedIndex = 0
        'If (cboxAttrib.Items.Count > 0) Then cboxAttrib.SelectedIndex = 0
        'If (cboxDomains.Items.Count > 0) Then cboxDomains.SelectedIndex = 0
    End Sub

    Private Sub openEAover(ByVal sOverview As String)
        Dim xmlEADoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim s1 As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim sList As String
        Dim oNewOver As New EAoverClass
        Dim sOverCite As New StringCollection

        xmlEADoc.LoadXml(sOverview)
        oNewOver = New EAoverClass
        sOverCite = New StringCollection

        'retrieve Entity & Attribute Overview
        xmlNlist = xmlEADoc.SelectNodes("/overview/eaover")
        If (xmlNlist.Count > 0) Then
            oNewOver.Overview = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Entity & Attribute Detail Citation(s)
        xmlNlist = xmlEADoc.SelectNodes("/overview/eadetcit")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            s1 = xmlNlist(iLoop).InnerText.Trim
            sOverCite.Add(s1)
        Next
        oNewOver.DetailCite = sOverCite 'put collection into object

        'update main overview collection and list box display
        f52.cEAttrOver.Add(oNewOver)
        s1 = oNewOver.Overview
        s1 = Replace(s1, sKdelim, "  ")
        sList = Microsoft.VisualBasic.Left(s1, 80)
        f52.lboxOverView.Items.Add(sList)
        Return
    End Sub

    Private Sub openEAdetail(ByVal sDetail As XmlNode)
        Dim importXML As String = sDetail.InnerXml()
        f51.addImportedNodes(sDetail)
    End Sub

#End Region

#Region " DOM processing for Distribution Information section "

    Private Sub openDistrib(ByVal xmlOpenDI As XmlDocument)
        Dim xmlNlist As XmlNodeList
        Dim xmlTime As New XmlDocument
        Dim sDistInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim oDistrib As New DistributorClass
        Dim oContact As New ContactInfo 'goes into oDistrib
        Dim oTime As New SourceClass 'used to process Available Time Period
        Dim cAvTime As New Collection 'goes into oDistrib
        Dim oStdOrder As New StdOrderClass
        Dim cStdOrderIndex As New Collection 'goes into oDistrib

        'initialize
        oDistrib = New DistributorClass
        oContact = New ContactInfo
        oStdOrder = New StdOrderClass
        cStdOrderIndex = New Collection
        cAvTime = New Collection

        'retrieve Distributor
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/distrib/cntinfo")
        If (xmlNlist.Count > 0) Then
            'get the Contact Information XML
            sDistInfo = xmlNlist(0).OuterXml
            openContact(sDistInfo, oContact)
            oDistrib.Distributor = oContact
        End If

        'retrieve Resource Description
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/resdesc")
        If (xmlNlist.Count > 0) Then
            oDistrib.ResourceDesc = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Distribution Liability
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/distliab")
        If (xmlNlist.Count > 0) Then
            oDistrib.Liability = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Custom Order Process
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/custom")
        If (xmlNlist.Count > 0) Then
            oDistrib.CustomOrder = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Technical Prerequisites
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/techpreq")
        If (xmlNlist.Count > 0) Then
            oDistrib.TechReq = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Available Time Period
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/availabl/timeinfo")

        If (xmlNlist.Count > 0) Then
            sDistInfo = xmlNlist(0).OuterXml
            xmlTime.LoadXml(sDistInfo)
            openTimeInfo(xmlTime, oTime, cAvTime)

            If (oTime.boolSingle = True And oTime.boolRange = False) Then
                'Single Date/Time
                oDistrib.boolSingle = True
                oDistrib.boolRange = False
            ElseIf (oTime.boolSingle = False And oTime.boolRange = True) Then
                'Range of Dates
                oDistrib.boolSingle = False
                oDistrib.boolRange = True
            ElseIf (oTime.boolSingle = False And oTime.boolRange = False) Then
                'Multiple Dates; requires translation
                oDistrib.boolSingle = True
                oDistrib.boolRange = True
            Else
                'unknown or no value
                oDistrib.boolSingle = False
                oDistrib.boolRange = False
            End If
            oDistrib.TimeAvail = cAvTime
        End If

        'retrieve Standard Order Process(es)
        xmlNlist = xmlOpenDI.SelectNodes("/distinfo/stdorder")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            sDistInfo = xmlNlist(iLoop).OuterXml
            openStdProc(sDistInfo, oStdOrder)
            'add new Standard Order to main collection
            f61.cStdOrderProc.Add(oStdOrder)
            'add index value of new Standard Order to index collection
            kCount = f61.cStdOrderProc.Count
            cStdOrderIndex.Add(kCount)
        Next

        'add Standard Order index collection to distributor object
        oDistrib.StdOrderColl = cStdOrderIndex

        f61.cDistrib.Add(oDistrib) 'add new distributor to main collection
        'identify distributor in list box using required contact information
        If (oContact.PrimaryPerson = True) Then
            sDistInfo = "Distributor, person: " & oContact.Person
        Else
            sDistInfo = "Distributor, organization: " & oContact.Organization
        End If
        f61.lboxDistrib.Items.Add(sDistInfo)
    End Sub

    Private Sub openStdProc(ByVal sOrder As String, ByRef oProcess As StdOrderClass)
        Dim xmlOrderProcDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sDistInfo As String = ""
        Dim cDigiForm As New Collection

        xmlOrderProcDoc.LoadXml(sOrder)
        oProcess = New StdOrderClass
        cDigiForm = New Collection

        'retrieve Fees
        xmlNlist = xmlOrderProcDoc.SelectNodes("/stdorder/fees")
        If (xmlNlist.Count > 0) Then
            oProcess.Fees = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Ordering Instructions
        xmlNlist = xmlOrderProcDoc.SelectNodes("/stdorder/ordering")
        If (xmlNlist.Count > 0) Then
            oProcess.Instructions = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Turnaround
        xmlNlist = xmlOrderProcDoc.SelectNodes("/stdorder/turnarnd")
        If (xmlNlist.Count > 0) Then
            oProcess.Turnaround = xmlNlist(0).InnerText.Trim
        End If

        'retrieve Non-digital Form
        xmlNlist = xmlOrderProcDoc.SelectNodes("/stdorder/nondig")
        If (xmlNlist.Count > 0) Then
            oProcess.NonDigitalForm = xmlNlist(0).InnerText.Trim
            Return
        End If

        'OR retrieve Digital Form(s)
        xmlNlist = xmlOrderProcDoc.SelectNodes("/stdorder/digform")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            sDistInfo = xmlNlist(iLoop).OuterXml
            openDigitForm(sDistInfo, kCount)
            If (kCount > 0) Then
                'add Digital Form index to collection
                cDigiForm.Add(kCount)
            End If
        Next
        oProcess.DigitalForms = cDigiForm 'add index collection to std order object
        Return
    End Sub

    Private Sub openDigitForm(ByVal sOrder As String, ByRef iFormVal As Integer)
        Dim xmlOrderProcDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim sDigiInfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim s1 As String = ""
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False
        Dim oDigiForm As New DigitalOrderClass
        Dim cDTransIndex As New Collection

        xmlOrderProcDoc.LoadXml(sOrder)
        cDTransIndex = New Collection
        iFormVal = 0

        'retrieve Digital Transfer Information
        xmlNlist = xmlOrderProcDoc.SelectNodes("/digform/digtinfo")
        If (xmlNlist.Count > 0) Then
            ' 1. retrieve Format Name
            xmlPlist = xmlNlist(0).SelectNodes("formname")
            If (xmlPlist.Count > 0) Then
                oDigiForm.FormatName = xmlPlist(0).InnerText.Trim
            End If
            ' 2a. retrieve Format Version Number
            bReal = False 'being used as test for presence of version number or version date
            xmlPlist = xmlNlist(0).SelectNodes("formvern")
            iCount = xmlPlist.Count
            If (iCount > 0) Then
                oDigiForm.FormatVNum = xmlPlist(0).InnerText.Trim
                bReal = True
            Else
                ' 2b. OR retrieve Format Version Date
                xmlPlist = xmlNlist(0).SelectNodes("formverd")
                If (xmlPlist.Count > 0) Then
                    oDigiForm.FormatVDate = xmlPlist(0).InnerText.Trim
                    bReal = True
                End If
            End If
            ' 3. retrieve Format Specification
            xmlPlist = xmlNlist(0).SelectNodes("formspec")
            If (xmlPlist.Count > 0) Then
                oDigiForm.FormatSpec = xmlPlist(0).InnerText.Trim
                If (bReal = False) Then oDigiForm.FormatVNum = "see Format Specification"
            End If
            ' 4. retrieve ASCII File Structure
            xmlPlist = xmlNlist(0).SelectNodes("asciistr")
            If (xmlPlist.Count > 0) Then
                sDigiInfo = xmlPlist(0).OuterXml
                openASCIIform(sDigiInfo, oDigiForm)
            End If
            ' 5. retrieve Format Information Content
            xmlPlist = xmlNlist(0).SelectNodes("formcont")
            If (xmlPlist.Count > 0) Then
                oDigiForm.FormatInfo = xmlPlist(0).InnerText.Trim
            End If
            ' 6. retrieve File Decompression Technique
            xmlPlist = xmlNlist(0).SelectNodes("filedec")
            If (xmlPlist.Count > 0) Then
                oDigiForm.Decompress = xmlPlist(0).InnerText.Trim
            End If
            ' 7. retrieve Transfer Size
            sTitle = "Distribution Information"
            xmlPlist = xmlNlist(0).SelectNodes("transize")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                realCheck(s1, rVal, bReal)
                If (bReal = True) Then
                    If (rVal > 0.0) Then
                        s1 = rVal.ToString
                    Else
                        sError = "Transfer Size of " & s1 & " is not > 0.0." & CrLf
                        sError += "Value set to blank."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        s1 = ""
                    End If
                Else
                    sError = "Transfer Size of " & s1 & " could not be converted to a number."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    s1 = ""
                End If
                oDigiForm.TransferSize = s1
            End If
        End If

        'retrieve Digital Transfer Option(s)
        xmlNlist = xmlOrderProcDoc.SelectNodes("/digform/digtopt")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            sDigiInfo = xmlNlist(iLoop).OuterXml
            openDigitTrans(sDigiInfo, kCount)
            If (kCount > 0) Then cDTransIndex.Add(kCount) 'add index of option to collection
        Next
        If (cDTransIndex.Count > 0) Then oDigiForm.TransOptions = cDTransIndex

        'add Digital Form to main collection, get index value and return
        f61.cDigitalForm.Add(oDigiForm)
        iFormVal = f61.cDigitalForm.Count
        Return
    End Sub

    Private Sub openASCIIform(ByVal sASCII As String, ByRef oDigiForm As DigitalOrderClass)
        'process ASCII File Structure
        Dim xmlASCIIformat As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim s1 As String = ""
        Dim sData As String
        Dim sDelim As String = "delim"
        Dim sWidth As String = "width"
        Dim sDataFields As New StringCollection
        Dim sTest() As String
        Dim bCheck As Boolean = False

        xmlASCIIformat.LoadXml(sASCII)
        sDataFields = New StringCollection

        '1. retrieve Record Delimiter
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/recdel")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.RecordDelim = xmlNlist(0).InnerText.Trim
        End If
        '2. retrieve Number Header Lines
        sTitle = "Distribution Information"
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/numheadl")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            chkInteger(s1, iCount, bCheck)
            If (bCheck = True) Then
                If (iCount > 0) Then
                    'satisfactory value
                    s1 = iCount.ToString
                    oDigiForm.ASCIIstruct = True
                Else
                    sError = "ASCII File Structure" & CrLf
                    sError += "Number of Header Lines of " & s1 & " is not > 0." & CrLf
                    sError += "Value set to blank."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    s1 = ""
                End If
            Else
                sError = "ASCII File Structure" & CrLf
                sError += "Number of Header Lines of " & s1 & " could not be converted to a number."
                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                s1 = ""
            End If
            oDigiForm.NumHeaders = s1
        End If
        '3. retrieve Description of Header Content
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/deschead")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.Header = xmlNlist(0).InnerText.Trim
        End If
        '4. retrieve Orientation
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/orienta")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.Orientation = xmlNlist(0).InnerText.Trim
        End If
        '5. retrieve Case Sensitive
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/casesens")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.CaseSensitive = xmlNlist(0).InnerText.Trim
        End If
        '6. retrieve Authentication
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/authent")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.Authentic = xmlNlist(0).InnerText.Trim
        End If
        '7. retrieve Quote Character
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/quotech")
        If (xmlNlist.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.QuoteChar = xmlNlist(0).InnerText.Trim
        End If
        '8. retrieve Data Field(s)
        xmlNlist = xmlASCIIformat.SelectNodes("/asciistr/datafiel")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            sData = ""
            ' a. retrieve Data Field Name
            s1 = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("dfieldnm")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
            End If
            sData += s1 & sPdelim
            ' b. retrieve Missing Value Code
            s1 = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("missingv")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
            End If
            sData += s1 & sPdelim
            ' c1. retrieve Data Field Width Delimiter
            s1 = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("dfwidthd")
            kLoop = xmlPlist.Count
            If (kLoop > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                sData += sDelim & sPdelim & s1
            Else
                ' c2. OR retrieve Data Field Width
                xmlPlist = xmlNlist(iLoop).SelectNodes("dfwidth")
                s1 = xmlPlist(0).InnerText.Trim
                chkInteger(s1, kCount, bCheck)
                If (bCheck = True) Then
                    If (kCount > 0) Then
                        'satisfactory value
                        s1 = kCount.ToString
                        sData += sWidth & sPdelim & s1
                    Else
                        sError = "ASCII File Structure" & CrLf
                        sError += "Data Field Width of " & s1 & " is not > 0." & CrLf
                        sError += "Value set to blank."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        s1 = ""
                    End If
                Else
                    sError = "ASCII File Structure" & CrLf
                    sError += "Data Field Width of " & s1 & " could not be converted to a number."
                    MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                    s1 = ""
                End If
            End If
            sTest = Split(s1, sPdelim)
            kCount = sTest.GetLength(0)
            If (kCount < 4) Then sData += sPdelim 'ensures 3 sPdelim characters for splitting
            If (sData.Length > 3) Then sDataFields.Add(sData) 'else: no values present, just delimiters
        Next
        If (sDataFields.Count > 0) Then
            oDigiForm.ASCIIstruct = True
            oDigiForm.DataFields = sDataFields
        End If
        Return
    End Sub

    Private Sub openDigitTrans(ByVal sOption As String, ByRef iTransVal As Integer)
        Dim xmlOptionDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim xmlRlist As XmlNodeList
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim rVal As Double = 0.0
        Dim bReal As Boolean = False
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim s1 As String = ""
        Dim sAddress As String = ""
        Dim oTransfer As New DTransOption

        xmlOptionDoc.LoadXml(sOption)
        oTransfer = New DTransOption
        iTransVal = 0

        'retrieve Online Option
        xmlNlist = xmlOptionDoc.SelectNodes("/digtopt/onlinopt")
        If (xmlNlist.Count > 0) Then
            oTransfer.boolOnline = True
            ' 1. retrieve Access Instructions
            xmlPlist = xmlNlist(0).SelectNodes("accinstr")
            If (xmlPlist.Count > 0) Then
                oTransfer.Access = xmlPlist(0).InnerText.Trim
            End If
            ' 2. retrieve Online Computer & Operating System
            xmlPlist = xmlNlist(0).SelectNodes("oncomp")
            If (xmlPlist.Count > 0) Then
                oTransfer.ComputerOS = xmlPlist(0).InnerText.Trim
            End If
            ' 3. retrieve Network Address Name(s)
            xmlPlist = xmlNlist(0).SelectNodes("computer/networka/networkr")
            iCount = xmlPlist.Count - 1
            sAddress = ""
            For iLoop = 0 To iCount
                s1 = xmlPlist(iLoop).InnerText.Trim
                If (s1 <> "") Then
                    sAddress += s1 & sKdelim
                End If
            Next
            oTransfer.NetworkName = sAddress
            f61.cDTransOpt.Add(oTransfer)
            iTransVal = f61.cDTransOpt.Count
            Return
        End If

        'OR retrieve Offline Option
        xmlNlist = xmlOptionDoc.SelectNodes("/digtopt/offoptn")
        If (xmlNlist.Count > 0) Then
            oTransfer.boolOffline = True
            ' 1. Offline Media
            xmlPlist = xmlNlist(0).SelectNodes("offmedia")
            If (xmlPlist.Count > 0) Then
                oTransfer.OfflineMedia = xmlPlist(0).InnerText.Trim
            End If
            ' 2. retrieve Recording Capacity
            xmlPlist = xmlNlist(0).SelectNodes("reccap")
            If (xmlPlist.Count > 0) Then
                ' a. retrieve Recording Density
                sTitle = "Distribution Information"
                xmlRlist = xmlPlist(0).SelectNodes("recden")
                iCount = xmlRlist.Count - 1
                sAddress = ""
                For iLoop = 0 To iCount
                    s1 = xmlRlist(iLoop).InnerText.Trim
                    realCheck(s1, rVal, bReal)
                    If (bReal = True) Then
                        If (rVal > 0.0) Then
                            s1 = rVal.ToString
                        Else
                            sError = "Recording Density of " & s1 & " is not > 0.0." & CrLf
                            sError += "Value set to blank."
                            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                            s1 = ""
                        End If
                    Else
                        sError = "Recording Density of " & s1 & " could not be converted to a number."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        s1 = ""
                    End If
                    If (s1 <> "") Then sAddress += s1 & sKdelim
                Next
                If (sAddress <> "") Then oTransfer.RecDensity = sAddress
                ' b. retrieve Recording Density Units
                xmlRlist = xmlPlist(0).SelectNodes("recdenu")
                If (xmlRlist.Count > 0) Then
                    oTransfer.DensityUnits = xmlRlist(0).InnerText.Trim
                End If
            End If
            ' 3. retrieve Recording Format(s)
            xmlPlist = xmlNlist(0).SelectNodes("recfmt")
            iCount = xmlPlist.Count - 1
            sAddress = ""
            For iLoop = 0 To iCount
                s1 = xmlPlist(iLoop).InnerText.Trim
                If (s1 <> "") Then
                    sAddress += s1 & sKdelim
                End If
            Next
            oTransfer.RecFormat = sAddress
            ' 4. Compatibility Information
            xmlPlist = xmlNlist(0).SelectNodes("compat")
            If (xmlPlist.Count > 0) Then
                oTransfer.Compatible = xmlPlist(0).InnerText.Trim
            End If

            f61.cDTransOpt.Add(oTransfer)
            iTransVal = f61.cDTransOpt.Count
        End If
        Return
    End Sub

#End Region

#Region " DOM processing for Metadata Reference Information section "

    Private Sub openMR(ByVal xmlOpenMR As XmlDocument)
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim iYr As Integer = 0
        Dim iMonth As Integer = 0
        Dim iDay As Integer = 0
        Dim sError As String = ""
        Dim sTitle As String = ""
        Dim sMRinfo As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim bInteger As Boolean = False
        Dim oContact As New ContactInfo

        'retrieve Metadata Date
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metd")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            readDate(s1, iYr, iMonth, iDay, bInteger)
            If (bInteger = True) Then
                f71.dtPick1.Value = New DateTime(iYr, iMonth, iDay)
            End If
        End If

        'retrieve Metadata Review Date
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metrd")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            readDate(s1, iYr, iMonth, iDay, bInteger)
            If (bInteger = True) Then
                ' 1. set check box so Review Date included in metadata output
                f71.chkRevDate.Checked = True
                ' 2. set the date
                f71.dtPick2.Value = New DateTime(iYr, iMonth, iDay)
            End If
        End If

        'retrieve Metadata Future Review Date
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metfrd")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            readDate(s1, iYr, iMonth, iDay, bInteger)
            If (bInteger = True) Then
                ' 1. set check box so Future Review Date included in metadata output
                f71.chkFRevDate.Checked = True
                ' 2. set the date
                f71.dtPick3.Value = New DateTime(iYr, iMonth, iDay)
            End If
        End If

        'retrieve Metadata Contact
        oContact = New ContactInfo
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metc/cntinfo")
        If (xmlNlist.Count > 0) Then
            'get the Contact Information XML
            sMRinfo = xmlNlist(0).OuterXml
            openContact(sMRinfo, oContact)
            f71.objMRcontact = oContact 'update the main object
            If (f71.objMRcontact.PrimaryPerson = True) Then 'update the form display
                f71.txtMRcontact.Text = f71.objMRcontact.Person
            Else
                f71.txtMRcontact.Text = f71.objMRcontact.Organization
            End If
        End If

        'retrieve Metadata Standard Name
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metstdn")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = "FGDC Content Standards for Digital Geospatial Metadata") Then
                'fix error in ESRI output
                s1 = "FGDC Content Standard for Digital Geospatial Metadata"
            End If
            iCount = f71.cboxStdName.FindStringExact(s1)
            If (s1 = "") Then
                f71.cboxStdName.SelectedIndex = 0
            Else
                If (iCount = -1) Then
                    f71.cboxStdName.Items.Add(s1)
                    f71.cboxStdName.SelectedIndex = f71.cboxStdName.Items.Count - 1
                Else
                    f71.cboxStdName.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Metadata Standard Version
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metstdv")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            iCount = f71.cboxStdVer.FindStringExact(s1)
            If (s1 = "") Then
                f71.cboxStdVer.SelectedIndex = 0
            Else
                If (iCount = -1) Then
                    f71.cboxStdVer.Items.Add(s1)
                    f71.cboxStdVer.SelectedIndex = f71.cboxStdVer.Items.Count - 1
                Else
                    f71.cboxStdVer.SelectedIndex = iCount
                End If
            End If
        End If

        'retrieve Metadata Time Convention
        '  this was processed when file initially opened

        'retrieve Metadata Access Constraints
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metac")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            f73.txtMRaccess.Text = s1
        End If

        'retrieve Metadata Use Constraints
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metuc")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            f73.txtMRuse.Text = s1
        End If

        'retrieve Metadata Security Information
        xmlNlist = xmlOpenMR.SelectNodes("/metainfo/metsi")
        If (xmlNlist.Count > 0) Then
            ' 1. retrieve Metadata Security Classification System
            xmlPlist = xmlNlist(0).SelectNodes("metscs")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                f73.txtMRClassSys.Text = s1
            End If
            ' 2. retrieve Metadata Security Classification
            xmlPlist = xmlNlist(0).SelectNodes("metsc")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                iCount = f73.cboxMRClass.FindStringExact(s1)
                If (s1 = "") Then
                    f73.cboxMRClass.SelectedIndex = -1
                Else
                    If (iCount = -1) Then
                        f73.cboxMRClass.Items.Add(s1)
                        f73.cboxMRClass.SelectedIndex = f73.cboxMRClass.Items.Count - 1
                    Else
                        f73.cboxMRClass.SelectedIndex = iCount
                    End If
                End If
            End If
            ' 3. retrieve Metadata Security Handling Description
            xmlPlist = xmlNlist(0).SelectNodes("metshd")
            If (xmlPlist.Count > 0) Then
                s1 = xmlPlist(0).InnerText.Trim
                f73.txtMRSecDesc.Text = s1
            End If
        End If

        'retrieve Metadata Extensions
        '  this capability is not implemented in the current version
    End Sub

    Private Sub readDate(ByVal s1 As String, ByRef iYr As Integer, ByRef iMonth As Integer, ByRef iDay As Integer, _
                         ByRef bCheck As Boolean)
        Dim iCount As Integer = 0
        Dim sError As String = ""
        Dim sTitle As String = ""
        'process a standard date string
        'default date is January 1, 2004
        iYr = 2004
        iMonth = 1
        iDay = 1
        bCheck = False
        If (s1.Length > 8) Then
            s1 = Microsoft.VisualBasic.Left(s1, 8)
            sError = "Metadata date too long." & CrLf & "Will attempt to process truncated value."
            sTitle = "Metadata Reference Information error"
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        ElseIf (s1.Length < 4) Then
            bCheck = False
            sError = "Metadata date too short." & CrLf & "No date will be processed."
            sTitle = "Metadata Reference Information error"
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If
        chkInteger(s1, iCount, bCheck)
        If (bCheck = True) Then
            'set the date
            iYr = Convert.ToInt32(Microsoft.VisualBasic.Left(s1, 4))
            If (s1.Length > 4) Then iMonth = Convert.ToInt32(Mid(s1, 5, 2))
            If (s1.Length > 6) Then iDay = Convert.ToInt32(Mid(s1, 7, 2))
        Else
            sError = "Metadata date not an integer." & CrLf & "No date will be processed."
            sTitle = "Metadata Reference Information error"
            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

#End Region


#Region " DOM processing routines for Citation Information section "

    Private Sub openCite(ByVal xmlCiteNode As XmlDocument, ByRef oCite As CiteInfo, ByRef bCheck As Boolean)
        'process the xmlCiteNode and place results in oCite
        'XML assumed to start with <citeinfo> compound element
        'only processes 1 citation; ignores any lworkcit branches
        'if successful, i.e., at least 1 mandatory element present, bCheck is set to True

        Dim s1 As String = ""
        Dim sTitle As String = ""
        Dim sError As String = ""
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim xmlCiteList As XmlNodeList

        bCheck = False
        oCite = New CiteInfo

        'process Originators
        s1 = ""
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/origin")
        iCount = xmlCiteList.Count - 1
        For iLoop = 0 To iCount
            s1 += xmlCiteList(iLoop).InnerText & CrLf
        Next
        If (s1 = "") Then
            oCite.Author = "Unknown"
        Else
            oCite.Author = fixStringCrLf(s1)
        End If

        'process Publication Date
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/pubdate")
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
            If (s1 = "Unpublished Material") Then s1 = "Unpublished material"
            Select Case s1
                Case "Unknown", "Unpublished material"
                    'valid entries
                Case Else
                    evalDate(s1, bCheck)
                    If (bCheck = True) Then
                        'have valid date
                    Else
                        sTitle = "Citation Info—Publication Date error"
                        sError = s1 & "  is not in correct date format."
                        sError += " Date set to Unknown."
                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        s1 = "Unknown"
                    End If
            End Select
        Else
            s1 = "Unknown"
        End If
        oCite.PubDate = s1

        'process Publication Time
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/pubtime")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
            chkTime(s1)
        End If
        oCite.PubTime = s1

        'process Title
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/title")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.Title = s1

        'process Edition
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/edition")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.Edition = s1

        'process Geospatial Data Presentation Form
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/geoform")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.Geoform = s1

        'process Series Information
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/serinfo/sername")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.SerialName = s1

        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/serinfo/issue")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.Issue = s1

        'process Publication Information
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/pubinfo/pubplace")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.PubPlace = s1

        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/pubinfo/publish")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.Publisher = s1

        'process Other Citation Details
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/othercit")
        s1 = ""
        If (xmlCiteList.Count > 0) Then
            s1 = xmlCiteList(0).InnerText
        End If
        oCite.OtherCit = s1

        'process Online Linkages
        s1 = ""
        xmlCiteList = xmlCiteNode.SelectNodes("/citeinfo/onlink")
        iCount = xmlCiteList.Count - 1
        For iLoop = 0 To iCount
            s1 += xmlCiteList(iLoop).InnerText & CrLf
        Next
        oCite.URLink = s1

        bCheck = True
        Return
    End Sub

    Private Function fixStringCrLf(ByVal strInput As String) As String
        'routine to remove extraneous CR/LF from string
        ' result is string containing non-empty substrings separated by single CR/LF
        Dim strValues() As String
        Dim intLen As Integer = 0
        Dim intPos As Integer = 0
        Dim bAdd As Boolean = False
        Dim strSingle As String = CrLf

        If (Len(strInput) = 0) Then 'if blank, return blank string
            Return strInput
        End If

        strValues = Split(strInput, strSingle)  'split using CR/LF as delimiter
        intLen = strValues.GetLength(0)         'get number of substrings found

        strInput = ""                           're-initialize string being parsed
        bAdd = False
        For intPos = 0 To intLen - 1            'add non-zero length substrings, separate with CR/LF
            If (strValues(intPos) <> "") Then
                If (bAdd = True) Then
                    strInput = strInput & CrLf & strValues(intPos)
                Else
                    'first non-blank entry is not preceded by CrLf
                    strInput = strValues(intPos)
                    bAdd = True
                End If
            End If
        Next

        Return strInput
    End Function
#End Region

#Region " DOM processing routines for Time Period Information section "

    Private Sub openTimeInfo(ByVal xmlTimeNodes As XmlDocument, ByRef oTime As SourceClass, ByRef cTimeColl As Collection)
        Dim xmlNList As XmlNodeList
        Dim xmlNList2 As XmlNodeList
        Dim xmlNList3 As XmlNodeList
        Dim xmlNList4 As XmlNodeList
        Dim sTitle As String = ""
        Dim sError As String = ""
        Dim iCount As Integer = 0
        Dim iCount2 As Integer = 0
        Dim iCount3 As Integer = 0
        Dim iLoop As Integer = 0
        Dim oSngTimeBeg As New SngDateTime 'single date/time or beginning date/time
        Dim oSngTimeEnd As New SngDateTime 'ending date/time
        Dim oGeolBeg As New GeolAge 'beginning geologic age or single geologic age
        Dim oGeolEnd As New GeolAge 'ending geologic age
        Dim bTimeTypeSet As Boolean = False
        Dim sTimeElem As String = ""
        Dim xmlGeolNode As New XmlDocument 'for processing Geologic Age
        Dim bCheck As Boolean = False 'general boolean for checking success of subroutine

        oTime = New SourceClass
        cTimeColl = New Collection
        'initialize date type to be None/Unknown
        oTime.boolRange = True
        oTime.boolSingle = True

        'check for Single Date/Time
        xmlNList = xmlTimeNodes.SelectNodes("/timeinfo/sngdate")
        If (xmlNList.Count > 0) Then
            'working with Single Date/Time
            oTime.boolSingle = True
            oTime.boolRange = False
            xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/sngdate/caldate")
            If (xmlNList2.Count > 0) Then
                'working with Gregorian time
                oTime.Gregorian = True
                bTimeTypeSet = True
                'get the calendar date
                sTimeElem = xmlTimeNodes.SelectSingleNode("/timeinfo/sngdate/caldate").InnerText
                Select Case sTimeElem
                    Case "Unknown"
                        oTime.boolRange = True
                        oTime.boolSingle = True
                        Return
                    Case Else
                        evalDate(sTimeElem, bCheck)
                        If (bCheck = True) Then
                            'have valid date
                        Else
                            sTitle = "Time Period Info — Date error"
                            sError = sTimeElem & "  is not in correct date format." & CrLf
                            sError += "Date set to Unknown."
                            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                            sTimeElem = "Unknown"
                            oTime.boolRange = True
                            oTime.boolSingle = True
                            Return
                        End If
                End Select
                oSngTimeBeg.SngDate = sTimeElem
                'check for time of day
                xmlNList3 = xmlTimeNodes.SelectNodes("/timeinfo/sngdate/time")
                If (xmlNList3.Count > 0) Then
                    sTimeElem = xmlTimeNodes.SelectSingleNode("/timeinfo/sngdate/time").InnerText
                    If (sTimeElem = "Unknown") Then
                        'do nothing -- Unknown times are deleted
                    Else
                        chkTime(sTimeElem) 'make sure the time string conforms to stated time convention
                        oSngTimeBeg.TimeOfDay = sTimeElem
                    End If
                End If
                cTimeColl.Add(oSngTimeBeg) 'put date/time info into collection
                Return
            End If
            xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/sngdate/geolage")
            If (xmlNList2.Count > 0) Then
                'working with Geologic Age
                oTime.Gregorian = False
                bTimeTypeSet = True
                sTimeElem = xmlTimeNodes.SelectSingleNode("/timeinfo/sngdate/geolage").OuterXml
                xmlGeolNode.LoadXml(sTimeElem)
                openGeolAge(xmlGeolNode, oGeolBeg, bCheck)
                If (bCheck = True) Then
                    cTimeColl.Add(oGeolBeg) 'add the Geologic Age to the time period collection
                End If
            End If 'end single geologic age
            Return
        End If 'end single date/time instance

        'check for Multiple Dates/Times
        xmlNList = xmlTimeNodes.SelectNodes("/timeinfo/mdattim")
        If (xmlNList.Count > 0) Then
            'working with Multiple Dates/Times
            oTime.boolSingle = False
            oTime.boolRange = False
            xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/mdattim/sngdate") 'get the multiple single date nodes
            If (xmlNList2.Count > 0) Then
                iCount = xmlNList2.Count - 1 'number of single date/time to process, offset for 0-based index
                xmlNList3 = xmlNList2(0).SelectNodes("caldate")
                iCount2 = xmlNList3.Count
                If (iCount2 > 0) Then
                    'working with Gregorian times
                    oTime.Gregorian = True
                    bTimeTypeSet = True
                    For iLoop = 0 To iCount
                        oSngTimeBeg = New SngDateTime 're-initialize the date/time object
                        xmlNList3 = xmlNList2(iLoop).SelectNodes("caldate")
                        If (xmlNList3.Count > 0) Then
                            'get the calendar date
                            sTimeElem = xmlNList3(0).InnerText
                            Select Case sTimeElem
                                Case "Unknown"
                                    'do nothing
                                Case Else
                                    evalDate(sTimeElem, bCheck)
                                    If (bCheck = True) Then
                                        'have valid date
                                        oSngTimeBeg.SngDate = sTimeElem
                                        'process optional Time of Day, if present
                                        xmlNList3 = xmlNList2(iLoop).SelectNodes("time")
                                        If (xmlNList3.Count > 0) Then
                                            sTimeElem = xmlNList3(0).InnerText
                                            If (sTimeElem = "Unknown") Then
                                                'do nothing -- Unknown times are deleted
                                            Else
                                                chkTime(sTimeElem) 'make sure the time string conforms to stated time convention
                                                oSngTimeBeg.TimeOfDay = sTimeElem
                                            End If
                                        End If
                                        cTimeColl.Add(oSngTimeBeg) 'put date/time info into collection
                                    Else
                                        sTitle = "Time Period Info — Multiple Date error"
                                        sError = sTimeElem & "  is not in correct date format." & CrLf
                                        sError += "Date set to Unknown."
                                        MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                                        sTimeElem = "Unknown"
                                        oTime.boolRange = True
                                        oTime.boolSingle = True
                                        Return
                                    End If
                            End Select
                        End If
                    Next
                    If (cTimeColl.Count = 0) Then
                        'value is "Unknown"
                        oTime.boolSingle = True
                        oTime.boolRange = True
                    End If
                    If (cTimeColl.Count = 1) Then
                        'type is actually Single
                        oTime.boolSingle = True
                        oTime.boolRange = False
                    End If
                    Return
                Else
                    'working with Geologic times
                    oTime.Gregorian = False
                    bTimeTypeSet = True
                    For iLoop = 0 To iCount
                        oGeolBeg = New GeolAge 're-initialize the Geologic Age object
                        xmlNList3 = xmlNList2(iLoop).SelectNodes("geolage")
                        If (xmlNList3.Count > 0) Then
                            'there should be only 1 <geolage> node for each single date/time node
                            'so only process the 1st instance
                            sTimeElem = xmlNList3(0).OuterXml
                            xmlGeolNode.LoadXml(sTimeElem)
                            openGeolAge(xmlGeolNode, oGeolBeg, bCheck)
                            If (bCheck = True) Then
                                cTimeColl.Add(oGeolBeg) 'add the Geologic Age to the time period collection
                            End If
                        End If 'end single geologic age
                    Next
                    If (cTimeColl.Count = 0) Then
                        'value is "Unknown"
                        oTime.boolSingle = True
                        oTime.boolRange = True
                    End If
                    If (cTimeColl.Count = 1) Then
                        'type is actually Single
                        oTime.boolSingle = True
                        oTime.boolRange = False
                    End If
                    Return
                End If
            Else
                'no single date/time child nodes!
            End If
        End If 'end multiple date/time instance

        'check for Range of Date/Time
        xmlNList = xmlTimeNodes.SelectNodes("/timeinfo/rngdates")
        If (xmlNList.Count > 0) Then
            'working with Range of Date/Time
            oTime.boolSingle = False
            oTime.boolRange = True
            xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/rngdates/begdate")
            iCount = xmlNList2.Count
            If (iCount > 0) Then
                'working with Gregorian time
                oTime.Gregorian = True
                bTimeTypeSet = True
                'get the beginning calendar date
                sTimeElem = xmlNList2(0).InnerText
                Select Case sTimeElem
                    Case "Unknown"
                        oTime.boolRange = True
                        oTime.boolSingle = True
                        Return
                    Case Else
                        evalDate(sTimeElem, bCheck)
                        If (bCheck = True) Then
                            'have valid date
                        Else
                            sTitle = "Time Period Info — Range Date error"
                            sError = sTimeElem & "  is not in correct date format." & CrLf
                            sError += "Date set to Unknown."
                            MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                            sTimeElem = "Unknown"
                            oTime.boolRange = True
                            oTime.boolSingle = True
                            Return
                        End If
                End Select
                oSngTimeBeg.SngDate = sTimeElem
                'check for beginning time of day
                xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/rngdates/begtime")
                If (xmlNList2.Count > 0) Then
                    sTimeElem = xmlNList2(0).InnerText
                    If (sTimeElem = "Unknown") Then
                        'do nothing -- Unknown times are deleted
                    Else
                        chkTime(sTimeElem) 'make sure the time string conforms to stated time convention
                        oSngTimeBeg.TimeOfDay = sTimeElem
                    End If
                End If
                cTimeColl.Add(oSngTimeBeg) 'put beginning date/time info into collection

                'get the ending calendar date
                xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/rngdates/enddate")
                If (xmlNList2.Count > 0) Then
                    sTimeElem = xmlNList2(0).InnerText
                    Select Case sTimeElem
                        Case "Unknown"
                            oTime.boolRange = True
                            oTime.boolSingle = True
                            Return
                        Case Else
                            evalDate(sTimeElem, bCheck)
                            If (bCheck = True) Then
                                'have valid date
                            Else
                                sTitle = "Time Period Info — Range Date error"
                                sError = sTimeElem & "  is not in correct date format." & CrLf
                                sError += "Date set to Unknown."
                                MessageBox.Show(sError, sTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
                                sTimeElem = "Unknown"
                                oTime.boolRange = True
                                oTime.boolSingle = True
                                Return
                            End If
                    End Select
                    oSngTimeEnd.SngDate = sTimeElem
                End If
                'check for ending time of day
                xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/rngdates/endtime")
                If (xmlNList2.Count > 0) Then
                    sTimeElem = xmlNList2(0).InnerText
                    If (sTimeElem = "Unknown") Then
                        'do nothing -- Unknown times are deleted
                    Else
                        chkTime(sTimeElem) 'make sure the time string conforms to stated time convention
                        oSngTimeEnd.TimeOfDay = sTimeElem
                    End If
                End If
                cTimeColl.Add(oSngTimeEnd) 'put date/time info into collection
                If (cTimeColl.Count = 0) Then
                    'value is "Unknown"
                    oTime.boolSingle = True
                    oTime.boolRange = True
                End If
                If (cTimeColl.Count = 1) Then
                    'type is actually Single
                    oTime.boolSingle = True
                    oTime.boolRange = False
                End If
                Return
            End If

            xmlNList2 = xmlTimeNodes.SelectNodes("/timeinfo/rngdates/beggeol")
            If (xmlNList2.Count > 0) Then
                'working with Beginning Geologic Age
                oTime.Gregorian = False
                bTimeTypeSet = True
                sTimeElem = xmlTimeNodes.SelectSingleNode("/timeinfo/rngdates/beggeol").InnerXml
                xmlGeolNode.LoadXml(sTimeElem)
                openGeolAge(xmlGeolNode, oGeolBeg, bCheck)
                If (bCheck = True) Then
                    cTimeColl.Add(oGeolBeg) 'add the Geologic Age to the time period collection
                End If

                'working with Ending Geologic Age
                sTimeElem = xmlTimeNodes.SelectSingleNode("/timeinfo/rngdates/endgeol").InnerXml
                xmlGeolNode.LoadXml(sTimeElem)
                openGeolAge(xmlGeolNode, oGeolEnd, bCheck)
                If (bCheck = True) Then
                    cTimeColl.Add(oGeolEnd) 'add the Geologic Age to the time period collection
                End If
            End If 'end of geologic age
            If (cTimeColl.Count = 0) Then
                'value is "Unknown"
                oTime.boolSingle = True
                oTime.boolRange = True
            End If
            If (cTimeColl.Count = 1) Then
                'type is actually Single
                oTime.boolSingle = True
                oTime.boolRange = False
            End If
            Return
        End If 'end range of date/time instance

    End Sub

    Private Sub chkTime(ByRef sTime As String)
        Dim iPos As Integer
        Dim sConvFix1 As String = ""
        Dim sConvFix2 As String = ""

        sConvFix2 = "Time format converted to specified standard"

        'if local time is expected
        If (intTimeStyle = 1) Then
            'check for Universal Time
            iPos = sTime.IndexOf("Z") 'index starts at zero
            If (iPos > 0) Then
                'remove the Z
                sTime = sTime.Substring(0, iPos)
                sConvFix1 = "Universal Time converted to Local Time"
                MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            End If

            'check for Local + Differential
            iPos = sTime.IndexOf("+")
            If (iPos > 0) Then
                'remove the differential
                sTime = sTime.Substring(0, iPos)
                sConvFix1 = "Local + Differential Time converted to Local Time"
                MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            End If

            Return 'if already local time
        End If

        'if local + differential is expected
        If (intTimeStyle = 2) Then
            'check for Local + Differential
            iPos = sTime.IndexOf("+")
            If (iPos > 0) Then
                'right format!
                Return
            End If

            'check for Universal Time
            iPos = sTime.IndexOf("Z") 'index starts at zero
            If (iPos > 0) Then
                'remove the Z
                sTime = sTime.Substring(0, iPos)
                'add a placeholder differential
                sTime += "+0000"
                sConvFix1 = "Universal Time converted to Local Time + Differential"
                MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            End If

            'if local time, add a placeholder differential
            sTime += "+0000"
            sConvFix1 = "Local Time converted to Local Time + Differential"
            MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Return
        End If

        'if universal time is expected
        If (intTimeStyle = 3) Then
            'check for Universal Time
            iPos = sTime.IndexOf("Z") 'index starts at zero
            If (iPos > 0) Then
                'right format!
                Return
            End If

            'check for Local + Differential
            iPos = sTime.IndexOf("+")
            If (iPos > 0) Then
                'remove the differential, then add Z
                sTime = sTime.Substring(0, iPos)
                sTime += "Z"
                sConvFix1 = "Local + Differential Time converted to Universal Time"
                MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            End If

            'if local time, add a placeholder Z
            sTime += "Z"
            sConvFix1 = "Local Time converted to Universal Time"
            MessageBox.Show(sConvFix1, sConvFix2, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Return
        End If

    End Sub

    Private Sub openGeolAge(ByVal xmlGeolNode As XmlDocument, ByRef oGeol As GeolAge, ByRef bCheck As Boolean)
        'the root element of xmlGeolNode is <geolage>
        Dim xmlNList As XmlNodeList
        Dim xmlNList2 As XmlNodeList
        Dim iCount As Integer = 0
        Dim iCount2 As Integer = 0
        Dim iLoop As Integer = 0
        Dim sTimeElem As String = ""
        Dim xmlCiteNode As New XmlDocument 'for processing Geologic Citation
        Dim bCiteCheck As Boolean = False 'boolean for checking success of citation subroutine
        Dim bLWC As Boolean = False
        Dim oCite As New CiteInfo

        bCheck = False 'intialize subroutine success to False
        oGeol = New GeolAge
        'get the geologic time scale
        xmlNList = xmlGeolNode.SelectNodes("/geolage/geolscal")
        If (xmlNList.Count > 0) Then
            oGeol.TimeScale = xmlGeolNode.SelectSingleNode("/geolage/geolscal").InnerText
            bCheck = True
        End If
        'get the geologic age estimate
        xmlNList = xmlGeolNode.SelectNodes("/geolage/geolest")
        If (xmlNList.Count > 0) Then
            oGeol.Estim = xmlGeolNode.SelectSingleNode("/geolage/geolest").InnerText
            bCheck = True
        End If
        'get the geologic age uncertainty
        xmlNList = xmlGeolNode.SelectNodes("/geolage/geolun")
        If (xmlNList.Count > 0) Then
            oGeol.Uncert = xmlGeolNode.SelectSingleNode("/geolage/geolun").InnerText
            bCheck = True
        End If
        'get the geologic age explanation
        xmlNList = xmlGeolNode.SelectNodes("/geolage/geolexpl")
        If (xmlNList.Count > 0) Then
            oGeol.Explain = xmlGeolNode.SelectSingleNode("/geolage/geolexpl").InnerText
            bCheck = True
        End If
        'get any geologic citations
        xmlNList = xmlGeolNode.SelectNodes("/geolage/geolcit")
        If (xmlNList.Count > 0) Then
            bCheck = True
            iCount = xmlNList.Count - 1
            For iLoop = 0 To iCount
                'process the citation
                xmlCiteNode = New XmlDocument
                sTimeElem = xmlNList(iLoop).InnerXml
                xmlCiteNode.LoadXml(sTimeElem)
                'the InnerXml will get a citeinfo, including any larger work citation nodes
                'need to call the citeinfo processing routine, then place results into oGeol
                openCite(xmlCiteNode, oCite, bCiteCheck)
                If (bCiteCheck = True) Then
                    oGeol.GCiteAdd() 'add new citation to collection
                    iCount2 = oGeol.GCiteCount 'get index of the new citation
                    oGeol.GCiteUpdate(oCite, iCount2) 'update new citation with current citation info
                    'check for presence of a larger work citation
                    xmlNList2 = xmlCiteNode.SelectNodes("/citeinfo/lworkcit")
                    If (xmlNList2.Count > 0) Then
                        'process the larger work citation
                        sTimeElem = xmlCiteNode.SelectSingleNode("/citeinfo/lworkcit").InnerXml
                        xmlCiteNode.LoadXml(sTimeElem) 'holds the larger work citation
                        'the InnerXml will get the citeinfo under lworkcit
                        'need to call the citeinfo processing routine, then place results into oGeol
                        openCite(xmlCiteNode, oCite, bLWC)
                        If (bLWC = True) Then
                            oGeol.GLWCUpdate(bLWC, oCite, iCount2) 'update new citation with current LWC info
                        End If
                    End If 'end processing of larger work citation
                End If 'end processing of geologic citation
            Next
        End If 'ends handling of geologic age citations
    End Sub

#End Region

#Region " DOM processing routines for Contact Information section "

    Private Sub openContact(ByVal sContact As String, ByRef oContact As ContactInfo)
        Dim xmlContactDoc As New XmlDocument
        Dim xmlNlist As XmlNodeList
        Dim xmlPlist As XmlNodeList
        Dim iCount As Integer = 0
        Dim iLoop As Integer = 0
        Dim kCount As Integer = 0
        Dim kLoop As Integer = 0
        Dim s1 As String = ""
        Dim s2 As String = ""
        Dim sAddress As String = ""

        xmlContactDoc.LoadXml(sContact)
        oContact = New ContactInfo

        'process Primary Contact
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntperp")
        iCount = xmlNlist.Count
        If (iCount > 0) Then
            'Contact Person Primary
            oContact.PrimaryPerson = True
            xmlPlist = xmlNlist(0).SelectNodes("cntper")
            If (xmlPlist.Count > 0) Then 'fill in contact person
                s1 = xmlPlist(0).InnerText.Trim
                oContact.Person = s1
            End If
            xmlPlist = xmlNlist(0).SelectNodes("cntorg")
            If (xmlPlist.Count > 0) Then 'fill in contact organization
                s1 = xmlPlist(0).InnerText.Trim
                oContact.Organization = s1
            End If
        Else
            xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntorgp")
            kCount = xmlNlist.Count
            If (kCount > 0) Then
                'Contact Organization Primary
                oContact.PrimaryPerson = False
                xmlPlist = xmlNlist(0).SelectNodes("cntorg")
                If (xmlPlist.Count > 0) Then 'fill in contact organization
                    s1 = xmlPlist(0).InnerText.Trim
                    If (s1 = sKdelim) Then s1 = ""
                    oContact.Organization = s1
                End If
                xmlPlist = xmlNlist(0).SelectNodes("cntper")
                If (xmlPlist.Count > 0) Then 'fill in contact person
                    s1 = xmlPlist(0).InnerText.Trim
                    If (s1 = sKdelim) Then s1 = ""
                    oContact.Person = s1
                End If
            End If
        End If

        'Contact Position, if present
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntpos")
        If (xmlNlist.Count > 0) Then
            s1 = xmlNlist(0).InnerText.Trim
            If (s1 = sKdelim) Then s1 = ""
            oContact.Position = s1
        End If

        'process Contact Address
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntaddr")
        iCount = xmlNlist.Count - 1
        For iLoop = 0 To iCount
            'build the address string
            sAddress = ""
            xmlPlist = xmlNlist(iLoop).SelectNodes("addrtype") 'get address type
            If (xmlPlist.Count > 0) Then
                sAddress += xmlPlist(0).InnerText.Trim
            End If
            sAddress += sPdelim
            xmlPlist = xmlNlist(iLoop).SelectNodes("address") 'get the address line(s)
            kCount = xmlPlist.Count - 1
            s1 = ""
            For kLoop = 0 To kCount
                s1 += xmlPlist(kLoop).InnerText.Trim & sKdelim
            Next
            sAddress += s1 & sPdelim
            xmlPlist = xmlNlist(iLoop).SelectNodes("city") 'get city
            If (xmlPlist.Count > 0) Then
                sAddress += xmlPlist(0).InnerText.Trim
            End If
            sAddress += sPdelim
            xmlPlist = xmlNlist(iLoop).SelectNodes("state") 'get state or province
            If (xmlPlist.Count > 0) Then
                sAddress += xmlPlist(0).InnerText.Trim
            End If
            sAddress += sPdelim
            xmlPlist = xmlNlist(iLoop).SelectNodes("postal") 'get postal code
            If (xmlPlist.Count > 0) Then
                sAddress += xmlPlist(0).InnerText.Trim
            End If
            sAddress += sPdelim
            xmlPlist = xmlNlist(iLoop).SelectNodes("country") 'get country
            If (xmlPlist.Count > 0) Then
                sAddress += xmlPlist(0).InnerText.Trim
            End If
            If (sAddress.Length > 6) Then
                oContact.AddressAdd(sAddress) 'put completed address into collection of addresses
            End If
        Next

        'process Voice Telephone
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntvoice")
        iCount = xmlNlist.Count - 1
        sAddress = ""
        For iLoop = 0 To iCount
            'build the voice telephone string
            sAddress += xmlNlist(iLoop).InnerText.Trim & sKdelim
        Next
        oContact.VoiceTel = sAddress 'put completed telephone set into object

        'process TDD/TTY Telephone
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cnttdd")
        iCount = xmlNlist.Count - 1
        sAddress = ""
        For iLoop = 0 To iCount
            'build the TDD telephone string
            sAddress += xmlNlist(iLoop).InnerText.Trim & sKdelim
        Next
        oContact.TDDtel = sAddress 'put completed TDD telephone set into object

        'process Fax Telephone
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntfax")
        iCount = xmlNlist.Count - 1
        sAddress = ""
        For iLoop = 0 To iCount
            'build the fax telephone string
            sAddress += xmlNlist(iLoop).InnerText.Trim & sKdelim
        Next
        oContact.FaxTel = sAddress 'put completed fax telephone set into object

        'process E-mail address(es)
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntemail")
        iCount = xmlNlist.Count - 1
        sAddress = ""
        For iLoop = 0 To iCount
            'build the e-mail string
            sAddress += xmlNlist(iLoop).InnerText.Trim & sKdelim
        Next
        oContact.Email = sAddress 'put completed e-mail set into object

        'process Hours of Service
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/hours")
        If (xmlNlist.Count > 0) Then
            oContact.Hours = xmlNlist(0).InnerText.Trim
        End If

        'process Contact Instructions
        xmlNlist = xmlContactDoc.SelectNodes("/cntinfo/cntinst")
        If (xmlNlist.Count > 0) Then
            oContact.Instructions = xmlNlist(0).InnerText.Trim
        End If
    End Sub

#End Region

#End Region

#Region "Toolbar Operations"
    Private Sub localTime()
        intTimeStyle = 1 'local time
        LocalToolStripMenuItem.Checked = True
        LocalDifferentToolStripMenuItem.Checked = False
        UniversalToolStripMenuItem1.Checked = False
    End Sub
    Private Sub differTime()
        intTimeStyle = 2 'local time with time differential factor
        LocalToolStripMenuItem.Checked = False
        LocalDifferentToolStripMenuItem.Checked = True
        UniversalToolStripMenuItem1.Checked = False
    End Sub
    Private Sub univTime()
        intTimeStyle = 3 'universal
        LocalToolStripMenuItem.Checked = False
        LocalDifferentToolStripMenuItem.Checked = False
        UniversalToolStripMenuItem1.Checked = True
    End Sub

    Private Sub runHelp()
        Dim helpForm As dialog_help = New dialog_help("Index")
        helpForm.ShowDialog()
    End Sub
    Private Sub runITIS()
        Dim helpForm As dialog_help = New dialog_help("ITIShelp")
        helpForm.ShowDialog()
    End Sub
    Private Sub runHelpAbout()
        Dim helpForm As dialog_help = New dialog_help("About")
        helpForm.ShowDialog()
    End Sub
    'Menu Items
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        runFileNew()
    End Sub
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        runFileSave("temp")
    End Sub
    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        runFileClose()
    End Sub
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        runFileOpen()
    End Sub
    Private Sub SaveToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        runSave()
    End Sub
    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
        runSaveAs()
    End Sub
    Private Sub ExportHTMLToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExportHTMLToolStripMenuItem.Click
        'added 4/19/2006 as sole new feature for version 1.2
        '1. get the URL for the desired XSLT style sheet
        '2. write the current metadata as XML to a temporary file
        '   use XPath calls in FileSave routine to navigate the DOM object and replace CRLF characters in 
        '   selected nodes with the special character "mvcrlf*" -- which should not ever appear in metadata content
        '3. apply the style sheet to generate intermediate HTML (save to temporary file)
        '4. open the intermediate HTML file and read it line by line, exchanging "<br/>" for "mvcrlf*"
        '   this will preserve the paragraph structure of the original metadata
        '5. write final HTML to final file destination
        '6. clean up temporary files

        Dim sError As String = ""

        '1. get the URL for the desired XSLT style sheet
        Dim strXSLurl As String = ""  'will hold the URL for the style sheet
        Dim iLength As Integer = 0
        Dim frmGetStyle As New frmXMLchangeStyle(strCurHref)  'standard dialog window for style sheet; defined in version 1.0
        frmGetStyle.ShowDialog()
        strXSLurl = frmGetStyle.strNewHref 'the stylesheet for the HTML export
        strXSLurl = strXSLurl.Trim  'make sure no extraneous leading or trailing characters

        If (Len(strXSLurl) = 0) Then  'null stylesheet
            MessageBox.Show("No XSL stylesheet specified. Export to HTML failed", "Save Failed", MessageBoxButtons.OK)
            Return
        End If

        iLength = strXSLurl.Length
        strXSLurl = strXSLurl.Substring(1, iLength - 2)
        strXSLurl = strXSLurl.Trim  'make sure no extraneous leading or trailing characters

        If (Len(strXSLurl) = 0) Then  'null stylesheet
            MessageBox.Show("No XSL stylesheet specified. Export to HTML failed", "Save Failed", MessageBoxButtons.OK)
            Return
        End If

        'need to make sure the style sheet file exists
        Dim testURL As System.IO.File
        Dim boolURL As Boolean = testURL.Exists(strXSLurl)
        If (boolURL) Then
            'everything is okay
        Else
            sError = "Style sheet file not found! HTML export aborted." & CrLf & "Tip: the style sheet browse feature is more reliable"
            MessageBox.Show(sError, "HTML export error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return
        End If

        '2. write the current metadata as XML to a temporary file
        '   use XPath calls in FileSave routine to navigate the DOM object and replace CRLF characters in 
        '   selected nodes with the special character "mvcrlf*" -- which should not ever appear in metadata content
        Dim strXMLtempfile As String = Application.StartupPath & "\mvtemp.xml"
        iSaveType = 2 'type 2 = save associated with HTML export
        Call runFileSave(strXMLtempfile)

        '3. apply the style sheet to generate intermediate HTML (save to temporary file)
        Dim xslTran As New System.Xml.Xsl.XslTransform
        Dim strHTMLtempfile As String = Application.StartupPath & "\mvtemp.html"
        Dim htmlMetafile As System.IO.FileStream
        Dim resolver As XmlUrlResolver = New XmlUrlResolver ' Create a resolver with default credentials.
        resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

        htmlMetafile = System.IO.File.Create(strHTMLtempfile)
        htmlMetafile.Close()

        xslTran.Load(strXSLurl) 'load stylesheet
        xslTran.Transform(strXMLtempfile, strHTMLtempfile, resolver) 'apply stylesheet

        '4. open the intermediate HTML file and read it line by line, exchanging "<br/>" for "mvcrlf*"
        '   this will preserve the paragraph structure of the original metadata
        Dim iLoop As Integer = 0
        Dim sGenArray As New StringCollection
        Dim sParagraphs As New StringCollection
        Dim srMeta As StreamReader
        htmlMetafile = System.IO.File.OpenRead(strHTMLtempfile)
        srMeta = New StreamReader(htmlMetafile)
        sGenArray.Add("<?xml version='1.0' encoding='UTF-8'?>")
        Do Until srMeta.Peek = -1
            sGenArray.Add(srMeta.ReadLine)
        Loop
        srMeta.Close()
        iLength = sGenArray.Count
        For iLoop = 0 To iLength - 1
            sParagraphs.Add(sGenArray(iLoop).Replace(strParaMarker, strParaHTML))
        Next
        sGenArray.Clear()

        '5. write final HTML to final file destination
        Dim strSaveHTML As String = "" 'holds pathname to HTML output file

        SaveHTMLDialog.ShowDialog()
        strSaveHTML = SaveHTMLDialog.FileName
        MessageBox.Show(strSaveHTML, "HTML final file name", MessageBoxButtons.OK)
        If (strSaveHTML <> "") Then
            Dim swHTML As StreamWriter = File.CreateText(strSaveHTML)
            For iLoop = 0 To iLength - 1
                swHTML.WriteLine(sParagraphs(iLoop))
            Next
            swHTML.Flush()
            swHTML.Close()
            sParagraphs.Clear()
        Else
            sError = "No file specified for HTML output" & CrLf & "Conversion not performed"
            MessageBox.Show(sError, "HTML conversion process", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

        System.IO.File.Delete(strXMLtempfile)
        System.IO.File.Delete(strHTMLtempfile)
    End Sub
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        If runFileClose() <> 0 Then Me.Dispose()
    End Sub
    Private Sub XMLStylesheetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles XMLStylesheetToolStripMenuItem.Click
        runXMLstyle()
    End Sub
    Private Sub LocalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LocalToolStripMenuItem.Click
        localTime()
    End Sub
    Private Sub LocalDifferentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LocalDifferentToolStripMenuItem.Click
        differTime()
    End Sub
    Private Sub UniversalToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UniversalToolStripMenuItem1.Click
        univTime()
    End Sub
    Private Sub MetavistHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MetavistHelpToolStripMenuItem.Click
        runHelp()
    End Sub
    Private Sub ITISImportHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ITISImportHelpToolStripMenuItem.Click
        runITIS()
    End Sub
    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        runHelpAbout()
    End Sub
    Private Sub UsabilitySurveyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsabilitySurveyToolStripMenuItem.Click
        Dim webAddress As String = "http://metavist.djames.net/UsabilitySurvey.aspx"
        Process.Start(webAddress)
    End Sub
    Private Sub CheckForUpdatesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdatesToolStripMenuItem.Click
        Dim webAddress As String = "http://metavist2.codeplex.com/Release/ProjectReleases.aspx"
        Process.Start(webAddress)
    End Sub
    Private Sub SettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingsToolStripMenuItem.Click
        Dim helpForm As dialog_help = New dialog_help("Settings")
        helpForm.ShowDialog()
    End Sub
    Private Sub VerifyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerifyToolStripMenuItem.Click
        Dim helpForm As dialog_help = New dialog_help("Verify")
        helpForm.ShowDialog()
    End Sub

    'Toolbar Items
    Private Sub tool_New_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_New.Click
        runFileNew()
    End Sub
    Private Sub tool_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_Open.Click
        runFileOpen()
    End Sub
    Private Sub tool_Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_Save.Click
        runSave()
    End Sub
    Private Sub tool_About_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_About.Click
        runHelpAbout()
    End Sub
    Private Sub tool_Help_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_Help.Click
        runHelp()
    End Sub
    Private Sub tool_verify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tool_verify.Click
        VerifyToolStripMenuItem_Click(sender, e)
    End Sub

    'Form closed from x
    Private Sub frmMain_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If runFileClose() <> 0 Then Me.Dispose() Else e.Cancel() = True
    End Sub
#End Region

#Region " Initialization routines for new metadata document "

    Private Sub InitialDOM()
        'initialize general variables
        localTime() 'set local time as default
        'xmlAttrib = xmlHeader.CreateAttribute("missing")
        'xmlAttrib.Value = "True"

        'clear input from all metadata elements
        initID()
        initDQ()
        initSPDO()
        initSpRef()
        initEA()
        initDI()
        initMR()
    End Sub

    Private Sub initID()
        'Basic information
        f11.objCitation = New CiteInfo
        f11.objCitationLWork = New CiteInfo
        f11.bCitationLWork = False
        f11.IDtimeper = New Collection
        'Spatial Domain
        f12.sDataSetGPoly = New StringCollection
        f12.sCountGPoly = New StringCollection
        'Keywords
        f13.sKeyTheme = New StringCollection
        f13.sKeyPlace = New StringCollection
        f13.sKeyStratum = New StringCollection
        f13.sKeyTemporal = New StringCollection
        'Taxonomy
        f14.sTaxKeywords = New StringCollection
        f14.citeTaxSys = New Collection 'holds the main citation information for Taxonomic System
        f14.boolTaxSys = New Collection 'holds Booleans indicating whether LWC is used
        f14.citeTaxSysLWC = New Collection 'holds larger work citations
        f14.sTaxSysMods = New StringCollection 'holds the Taxonomic System modifications
        f14.citeTaxIDRef = New Collection 'holds the main citation information for Identification Reference
        f14.boolTaxIDRef = New Collection 'holds Booleans indicating whether LWC is used
        f14.citeTaxIDRefLWC = New Collection 'holds larger work citations
        f14.cntTaxID = New Collection 'holds contact information for Identifier(s) -- optional
        f14.sVSpecimen = New StringCollection 'holds the specimen info for vouchers
        f14.cntVouchers = New Collection 'holds the contact info for voucher repository
        f14.TaxaClasses = New Collection 'holds the taxonomic classification nodes
        f14.xmlTaxonClass = New XmlDocument 'holds the taxonomic classification XML tree
        'Access
        f15.objDataContact = New ContactInfo 'only 1 point of contact
        'Analytical Tools
        f16.idTools = New Collection
        'Miscellaneous
        f17.sBrowseGraphics = New StringCollection
        f17.XRefBase = New Collection
        f17.bXRefLWC = New Collection
        f17.XRefLarge = New Collection

        clrIDinfo()
    End Sub

    Private Sub clrIDinfo()
        'Basic information
        f11.txtIDCiteAuth.Clear()
        f11.txtIDCiteDate.Clear()
        f11.txtIDCiteTitle.Clear()
        f11.txtAbstract.Clear()
        f11.txtPurpose.Clear()
        f11.txtSupplInfo.Clear()
        f11.rdoTUnknown.Checked = True
        f11.rdoTLocal.Checked = True
        f11.lboxTime.Items.Clear()
        f11.cboxCurRef.Text = ""
        f11.cboxCurRef.SelectedIndex = -1
        f11.lboxProg.SelectedIndex = -1
        f11.cboxUpdate.Text = ""
        f11.cboxUpdate.SelectedIndex = -1
        'Spatial Domain
        f12.txtGeoExt.Text = ""
        f12.numWestBC.Value = 0
        f12.numEastBC.Value = 0
        f12.numNorthBC.Value = 0
        f12.numSouthBC.Value = 0
        f12.numAltMin.Value = 0
        f12.numAltMax.Value = 0
        f12.cboxIDaltDistU.Text = ""
        f12.cboxIDaltDistU.SelectedIndex = -1
        f12.lboxGPoly.Items.Clear()
        'Keywords
        f13.lboxKTheme.Items.Clear()
        f13.lboxKPlace.Items.Clear()
        f13.lboxKStratum.Items.Clear()
        f13.lboxKTemporal.Items.Clear()
        'Taxonomy
        f14.txtTaxCover.Text = ""
        f14.txtTaxProc.Text = ""
        f14.txtTaxCover.Text = ""
        f14.lboxTaxKey.Items.Clear()
        f14.lboxTaxSys.Items.Clear()
        f14.lboxTaxIDRef.Items.Clear()
        f14.lboxVouchers.Items.Clear()
        f14.lboxLinneaus.Items.Clear()
        'Access
        f15.txtIDaccess.Text = ""
        f15.txtIDuse.Text = ""
        f15.txtDataContact.Text = ""
        f15.txtDataSecSys.Text = ""
        f15.cboxDataSecClass.Text = ""
        f15.cboxDataSecClass.SelectedIndex = -1
        f15.txtDataSecDesc.Text = ""
        'Analytical Tools
        f16.lboxTool.Items.Clear()
        'Miscellaneous
        f17.txtDScredit.Text = ""
        f17.txtDSenviron.Text = ""
        f17.lboxBrGraphic.Items.Clear()
        f17.lboxXRef.Items.Clear()

    End Sub

    Private Sub initDQ()
        'Attribute Accuracy
        f21.sAttribAcc = New StringCollection
        f21.txtAttribAcc.Text = ""
        f21.lboxAttribAcc.Items.Clear()
        'Consistency & Completeness
        f22.txtLogic.Text = ""
        f22.txtComplete.Text = ""
        'Positional Accuracy
        f23.txtHorAccRpt.Text = ""
        'sHPosAcc = New StringCollection
        f23.lboxHPosAcc.Items.Clear()
        f23.txtVertAccRpt.Text = ""
        f23.sVPosAcc = New StringCollection
        f23.lboxVPosAcc.Items.Clear()
        'Lineage
        f24.cMethods = New Collection
        f24.cSources = New Collection
        f24.cProcess = New Collection
        f24.lboxMeth.Items.Clear()
        f24.lboxLinSource.Items.Clear()
        f24.lboxProcess.Items.Clear()
        'Cloud Cover
        f25.rdoNoCloud.Checked = True
        f25.pnlCloud.Visible = False
        f25.numCloud.Value = 0
    End Sub

    Private Sub initSPDO()
        f32.sSDTS = New StringCollection 'holds collection of SDTS or VPF terms descriptions, if used
        'f31.bSDTS = False
        'f31.bVPF = False
        'Reference Mode
        f31.txtIndirect.Text = ""
        f31.cboxDirect.SelectedIndex = -1
        'Vector Information
        f32.lblVector.Visible = True
        f32.Panel12.Visible = False
        f32.rdoNoDesc.Checked = True
        f32.lboxTerms.Items.Clear()
        f32.cboxVPF.SelectedIndex = -1
        'Raster Information
        f33.lblRaster.Visible = True
        f33.Panel10.Visible = False
        f33.cboxRasType.SelectedIndex = -1
        f33.numRasRow.Value = 0
        f33.numRasCol.Value = 0
        f33.numRasVert.Value = 0
    End Sub

    Private Sub initSpRef()
        'Horizontal Coordinate System Definition
        'set up projection systems
        f41.rdoNone.Checked = True 'default is no definition
        f41.pnlGeographic.Enabled = False
        f41.numLatRes.Value = 0
        f41.numLongRes.Value = 0
        f41.cboxGeoCoorUnits.SelectedIndex = -1
        f41.pnlPlanar.Enabled = False
        f41.lboxPlanar.Items.Clear()
        f41.cPlanar = New Collection
        f41.pnlLocal.Enabled = False
        f41.txtLocalDesc.Text = ""
        f41.txtLocalGeoInfo.Text = ""
        'set up geodetic model
        f41.cboxHorizName.Text = ""
        f41.cboxHorizName.SelectedIndex = -1
        f41.cboxEllipsoid.Text = ""
        f41.cboxEllipsoid.SelectedIndex = -1
        f41.numSemiMajor.Value = 6378137D
        f41.numFlatten.Value = 298.25722210088D

        'Vertical Coordinate System Definition
        'Altitude sub-section
        f42.cboxAltDatum.Text = ""
        f42.cboxAltDatum.SelectedIndex = -1
        f42.numAltRes.Value = 0
        f42.txtAltRes.Text = ""
        f42.cboxAltUnits.Text = ""
        f42.cboxAltUnits.SelectedIndex = -1
        f42.cboxAltEncode.SelectedIndex = -1
        'Depth sub-section
        f42.cboxDepthDatum.Text = ""
        f42.cboxDepthDatum.SelectedIndex = -1
        f42.numDepthRes.Value = 0
        f42.txtDepthRes.Text = ""
        f42.cboxDepthUnits.Text = ""
        f42.cboxDepthUnits.SelectedIndex = -1
        f42.cboxDepthEncode.SelectedIndex = -1
    End Sub

    Private Sub initEA()
        f51.cEAentities = New Collection
        f51.cEAttribs = New Collection
        f51.cEAdomains = New Collection
        f51.cEAdomtypes = New Collection
        For Each item As TreeNode In f51.treeview_elements.Nodes(0).Nodes
            f51.treeview_elements.Nodes.Remove(item)
        Next
        'cEAdomtype.Add("unused") 'initialize 0th element so collection is 1-based
        f52.cEAttrOver = New Collection
        f52.lboxOverView.Items.Clear()
    End Sub

    Private Sub initDI()
        f61.cDistrib = New Collection 'the distributors of the data set
        f61.cStdOrderProc = New Collection 'standard order process descriptions
        f61.cDigitalForm = New Collection 'Digital forms for the standard order processes
        f61.cDTransOpt = New Collection 'Digital Transfer Options for Digital Forms
        f61.lboxDistrib.Items.Clear()
    End Sub

    Private Sub initMR()
        'Metadata information
        f71.objMRcontact = New ContactInfo 'only 1 possible contact
        f71.cboxStdName.SelectedIndex = 0
        f71.cboxStdVer.SelectedIndex = 0
        f71.txtMRcontact.Text = ""
        f71.chkRevDate.Checked = False
        f71.chkFRevDate.Checked = False
        f71.dtPick1.Value = Today
        f71.dtPick2.Value = Today
        f71.dtPick3.Value = Today
        'Constrataints Security
        f73.txtMRaccess.Text = ""
        f73.txtMRuse.Text = ""
        f73.txtMRClassSys.Text = ""
        f73.txtMRSecDesc.Text = ""
        f73.cboxMRClass.SelectedIndex = -1
        f73.cboxMRClass.Text = ""

    End Sub

#End Region

#Region "(Checked) Treeview Menu Extra Functions"
    Private Sub form_buttonShowHideMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles form_buttonShowHideMenu.Click
        If form_buttonShowHideMenu.Text.Contains("<") Then
            HideToolStripMenuItem_Click(sender, e)
        Else
            ShowToolStripMenuItem_Click(sender, e)
        End If
    End Sub
    Dim tip_showhidemenu As ToolTip = New ToolTip() 'Tooltip for the Show/Hide Button
    Private Sub ShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowToolStripMenuItem.Click
        form_buttonShowHideMenu.Text = "<<<"
        tip_showhidemenu.SetToolTip(form_buttonShowHideMenu, "Hide the Menu")
        form_Treeview.Width = 266
        ShowToolStripMenuItem.Enabled = False
        HideToolStripMenuItem.Enabled = True
    End Sub
    Private Sub HideToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideToolStripMenuItem.Click
        form_buttonShowHideMenu.Text = ">>>"
        tip_showhidemenu.SetToolTip(form_buttonShowHideMenu, "Show the Menu")
        form_Treeview.Width = 0
        ShowToolStripMenuItem.Enabled = True
        HideToolStripMenuItem.Enabled = False
    End Sub

    Private Sub ExpandAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExpandAllToolStripMenuItem.Click
        form_Treeview.ExpandAll()
    End Sub
    Private Sub CollapseAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CollapseAllToolStripMenuItem.Click
        form_Treeview.CollapseAll()
    End Sub

#End Region

End Class